Given a number N=117355392^3+262963008^3+107575776^3
state if it is a prime number or not.
(In reply to
re: Prime? by Danish Ahmed Khan)
While the problem doesn't ask for the factorization, now that your comment does:
5 Num=117355392^3+262963008^3+107575776^3:print Num
10 S$="":N=abs(Num)
20 if N>0 then Limit=sqrt(N):else Limit=0
30 if Limit<>int(Limit) then Limit=int(Limit+1)
40 Dv=2:gosub *DivideIt
50 Dv=3:gosub *DivideIt
60 Dv=5:gosub *DivideIt
70 Dv=7
80 loop
90 if Dv>Limit then goto *Afterloop
100 gosub *DivideIt:Dv=Dv+4 '11
110 gosub *DivideIt:Dv=Dv+2 '13
120 gosub *DivideIt:Dv=Dv+4 '17
130 gosub *DivideIt:Dv=Dv+2 '19
140 gosub *DivideIt:Dv=Dv+4 '23
150 gosub *DivideIt:Dv=Dv+6 '29
160 gosub *DivideIt:Dv=Dv+2 '31
170 gosub *DivideIt:Dv=Dv+6 '37
180 if inkey=chr(27) then S$=chr(27):end
190 endloop
200 *Afterloop
210 if N>1 then S$=S$+str(N)
220 print S$
230 end
240
250 *DivideIt
260 loop
270 Q=int(N/Dv)
280 if Q*Dv=N and N>0 then
290 :N=Q:S$=S$+str(Dv)
300 :if N>0 then Limit=sqrt(N):else Limit=0:endif
310 :if Limit<>int(Limit) then Limit=int(Limit+1):endif
320 :else
330 :goto *Afterdo
340 :endif
350 endloop
360 *Afterdo
370 return
OK
run
21044950027780650238181376
2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 3 3 3 3 3 3 7 7 7 7 7 7 7 7 7 11 11 11 4049 4051
meaning that N = 21044950027780650238181376, and the factorization is the listed primes, or more concisely:
2^15 * 3^6 * 7^9 * 11^3 * 4049 * 4051
|
Posted by Charlie
on 2012-10-30 17:06:29 |