37 lines
895 B
Text
37 lines
895 B
Text
function isprime( n as ulongint ) as boolean
|
|
if n mod 2 = 0 then return false
|
|
for i as uinteger = 3 to int(sqr(n))+1 step 2
|
|
if n mod i = 0 then return false
|
|
next i
|
|
return true
|
|
end function
|
|
|
|
function diff_cubes( n as uinteger ) as ulongint
|
|
return 3*n*(n+1) + 1
|
|
end function
|
|
|
|
function padto( n as uinteger, s as integer ) as string
|
|
dim as string outstr=""
|
|
dim as integer k = len(str(n))
|
|
for i as integer = 1 to s-k
|
|
outstr = " " + outstr
|
|
next i
|
|
return outstr + str(n)
|
|
end function
|
|
|
|
dim as integer nc = 0, i = 1, di
|
|
while nc < 100000
|
|
di = diff_cubes(i)
|
|
if isprime(di) then
|
|
nc += 1
|
|
if nc <= 200 then
|
|
print padto(di,8);" ";
|
|
if nc mod 10 = 0 then print
|
|
end if
|
|
if nc = 100000 then
|
|
print : print : print di
|
|
exit while
|
|
end if
|
|
end if
|
|
i += 1
|
|
wend
|