Created
January 28, 2016 15:40
-
-
Save stmtk1/ca05c004d0c9873c7312 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
int main(){ | |
int m, a, pow; | |
printf("法を入力"); | |
scanf("%d", &m); | |
printf("位数を求めたい数を入力"); | |
scanf("%d", &a); | |
pow = a; | |
for(int i = 2;i < m;i++){ | |
pow = (a * pow) % m; | |
if(pow == 1){ | |
printf("%d\n", i); | |
break; | |
} | |
if(i == (m - 1) && pow != 1){ | |
printf("位数はありません。お前が位数になるんだよ\n"); | |
} | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment