RosettaCodeData/Task/Blum-integer/FutureBasic/blum-integer.basic

48 lines
920 B
Plaintext

begin globals
UInt32 gPrime1
end globals
local fn IsSemiprime( n as UInt32 ) as BOOL
BOOL result = NO
UInt32 d = 3, c = 0
while d * d <= n
while ( n % d = 0 )
if ( c == 2 ) then return NO
n /= d
c += 1
wend
d += 2
wend
gPrime1 = n
result = ( c == 1 )
end fn = result
void local fn BlumIntegers
UInt32 prime2 = 0, n = 3, c = 0
print @"The first 50 Blum integers:"
while ( 1 )
if ( fn IsSemiprime( n ) )
if ( gPrime1 % 4 == 3 )
prime2 = n / gPrime1
if ( prime2 != gPrime1 ) && ( prime2 % 4 == 3 )
c++
if ( c <= 50 )
printf @"%4d\b",n
if ( c % 10 == 0 ) then print
end if
if ( c >= 26828 )
print : print @"The 26828th Blum integer is: "; n
break
end if
end if
end if
end if
n += 2
wend
end fn
fn BlumIntegers
HandleEvents