47 lines
1.0 KiB
Plaintext
47 lines
1.0 KiB
Plaintext
function is_prime( n as uinteger ) as boolean
|
|
if n = 2 then return true
|
|
if n<2 or n mod 2 = 0 then return false
|
|
for i as uinteger = 3 to sqr(n) step 2
|
|
if (n mod i) = 0 then return false
|
|
next i
|
|
return true
|
|
end function
|
|
|
|
function first_prime_factor( n as uinteger ) as uinteger
|
|
if n mod 2 = 0 then return 2
|
|
for i as uinteger = 3 to sqr(n) step 2
|
|
if (n mod i) = 0 then return i
|
|
next i
|
|
return n
|
|
end function
|
|
|
|
dim as uinteger count = 0, n = 0, ff, sf, expo = 0
|
|
|
|
while count<100
|
|
ff = first_prime_factor(n)
|
|
sf = n/ff
|
|
if is_prime(sf) and len(str(ff)) = len(str(sf)) then
|
|
print n,
|
|
count = count + 1
|
|
if count mod 6 = 0 then print
|
|
end if
|
|
n = n + 1
|
|
wend
|
|
print
|
|
count = 0
|
|
|
|
n = 0
|
|
do
|
|
ff = first_prime_factor(n)
|
|
sf = n/ff
|
|
if is_prime(sf) and len(str(ff)) = len(str(sf)) then
|
|
count = count + 1
|
|
if n > 10^expo then
|
|
print n;" is brilliant #"; count
|
|
expo = expo + 1
|
|
if expo = 9 then end
|
|
end if
|
|
end if
|
|
n = n + 1
|
|
loop
|