What is the smallest positive integer N that, when added to a googol (10^100), makes a prime number?
That number, a googol plus N, is called (UFINDIT).
10 point 80
20 x=10^100
30 y=fnNxprime(x)
40 print y
80 end
90 '
10000 fnOddfact(N)
10010 local K=0,P
10030 while N@2=0
10040 N=N\2
10050 K=K+1
10060 wend
10070 P=pack(N,K)
10080 return(P)
10090 '
10100 fnPrime(N)
10110 local I,X,J,Y,Q,K,T,Ans
10120 if N@2=0 then Ans=0:goto *EndPrime
10125 O=fnOddfact(N-1)
10130 Q=member(O,1)
10140 K=member(O,2)
10150 I=0
10160 repeat
10170 repeat
10180 X=fnLrand(N)
10190 until X>1
10200 J=0
10210 Y=modpow(X,Q,N)
10220 loop
10230 if or{and{J=0,Y=1},Y=N-1} then goto *ProbPrime
10240 if and{J>0,Y=1} then goto *NotPrime
10250 J=J+1
10260 if J=K then goto *NotPrime
10270 Y=(Y*Y)@N
10280 endloop
10290 *ProbPrime
10300 I=I+1
10310 until I>50
10320 Ans=1
10330 goto *EndPrime
10340 *NotPrime
10350 Ans=0
10360 *EndPrime
10370 return(Ans)
10380 '
10400 fnLrand(N)
10410 local R
10415 N=int(N)
10420 R=(int(rnd*10^(alen(N)+2)))@N
10430 return(R)
10440 '
10500 fnNxprime(X)
10510 if X@2=0 then X=X+1
10520 while fnPrime(X)=0
10530 X=X+2
10540 wend
10550 return(X)
10560 '
finds the next prime after a googol to be a googol plus 267.
This agrees with OEIS's A049014: n plus a googol is prime.
267, 949, 1243, 1293, 1983, 2773, 2809, 2911, 2967, 3469, 3501, 3799, 4317, 4447, 4491, 5383, 5641, 5949, 6403, 6637, 6903, 7443, 8583, 8653, 9013, 9223, 9259, 9631, 10071, 10557, 10833, 10903, 11143, 11173, 11529, 11667, 11839, 12207, 12817
https://sites.google.com/site/pointlesslargenumberstuff/home/l/pgln2?tmpl=%2Fsystem%2Fapp%2Ftemplates%2Fprint%2F&showPrintDialog=1
shows this as being called Gooprol, but the site has mostly humorous newly coined words.
|
Posted by Charlie
on 2018-08-02 12:25:55 |