41 lines
723 B
Text
41 lines
723 B
Text
function isprime(v)
|
|
if v mod 2 = 0 then return v = 2
|
|
for d = 3 To Int(Sqr(v))+1 Step 2
|
|
if v mod d = 0 then return false
|
|
next d3
|
|
return True
|
|
end function
|
|
|
|
function diff_cubes(n)
|
|
return 3*n*(n+1) + 1
|
|
end function
|
|
|
|
function padto(n, s)
|
|
outstr = ""
|
|
k = length(string(n))
|
|
for i = 1 to s-k
|
|
outstr = " " + outstr
|
|
next i
|
|
return outstr + string(n)
|
|
end function
|
|
|
|
print "Los primeros 200 primos cubanos son: "
|
|
|
|
nc = 0
|
|
i = 1
|
|
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 "El 100.000º primo cubano es ", di
|
|
exit while
|
|
end if
|
|
end if
|
|
i += 1
|
|
end while
|