hdu1395

来源:互联网 发布:手机新软件 编辑:程序博客网 时间:2024/06/01 09:08
#include<stdio.h>#include<math.h>int main(){    int n,x,i,t,flog;    while(scanf("%d",&n)==1)    {        if(n%2==0||n==1)        printf("2^? mod %d = 1\n",n);        else        {            t=1;flog=1;x=0;           while(t!=1||flog)           {               flog=0;               t*=2; t%=n;               x++;           }            printf("2^%d mod %d = 1\n",x,n);        }    }}