Skip to content

Instantly share code, notes, and snippets.

@stmtk1
Created January 28, 2016 15:40
Show Gist options
  • Save stmtk1/ca05c004d0c9873c7312 to your computer and use it in GitHub Desktop.
Save stmtk1/ca05c004d0c9873c7312 to your computer and use it in GitHub Desktop.
#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