Home > c/c++ > Code snippet found on my disk . . .

Code snippet found on my disk . . .

int m=167772161,N=1,t[1< &lt;25]={2},a,*p,i,e=34893349,s,c,U=1;g(d,h){for(i=s;i&lt;1<<
24;i*=2)d=d*1LL*d%m;for(p=t;p<t+N;p+=s)for(i=s,c=1;i;i--)a=p[s]*(h?c:1LL)%m,p[s]
=(m+*p-a)*(h?1LL:c)%m,a+=*p,*p++=a%m,c=c*1LL*d%m;}main(){while(e/=2){N*=2;U=U*
1LL*(m+1)/2%m;for(s=N;s/=2;)g(17,0);for(p=t;p<t+N;p++)*p=*p*1LL**p%m*U%m;for(s=1
;s<N;s*=2)g(29606852,1);for(a=0,p=t;p<t+N;)a+=*p<<(e&1),*p++=a%10,a/=10;}while(!
*--p);for(t[0]--;p>=t;)putchar(48+*p--);}

It is definitely not my code ;) . . . any guesses??

[update1]
As there were some offline discussions, here the original file as a download: Download File

[update2]
This is were I most probably got the code from: http://bellard.org/mersenne.html

Categories: c/c++ Tags:
  1. stefan
    July 12th, 2011 at 08:16 | #1

    If I have to guess…NRTM Christmas riddle???

  2. Malte
    October 13th, 2011 at 19:50 | #2

    It is a short code to find the largest primenumber as seen on: http://bellard.org/mersenne.html

  1. No trackbacks yet.