49 lines
1008 B
Plaintext
49 lines
1008 B
Plaintext
600000 eratosthenes
|
|
|
|
[ dup sqrt
|
|
tuck dup * = ] is exactsqrt ( n --> n b )
|
|
|
|
[ dup isprime iff
|
|
[ drop false ] done
|
|
dup 4 mod 1 != iff
|
|
[ drop false ] done
|
|
dup exactsqrt iff
|
|
[ 2drop false ] done
|
|
temp put
|
|
3 from
|
|
[ 4 incr
|
|
index temp share > iff
|
|
[ drop false end ]
|
|
done
|
|
index isprime not if done
|
|
dup index /mod 0 != iff
|
|
drop done
|
|
isprime not if done
|
|
drop index end ]
|
|
temp release ] is blum ( n --> n )
|
|
|
|
[ dup blum
|
|
over echo
|
|
say " = "
|
|
dup echo
|
|
say " * "
|
|
/ echo cr ] is echoblum ( n --> )
|
|
|
|
say "The First 50 Blum integers:"
|
|
cr cr
|
|
[] 1 from
|
|
[ 4 incr
|
|
index blum if
|
|
[ index join ]
|
|
dup size 50 = if end ]
|
|
witheach echoblum
|
|
cr
|
|
say "The 26828th Blum integer:"
|
|
cr cr
|
|
0 1 from
|
|
[ 4 incr
|
|
index blum if 1+
|
|
dup 26828 = if
|
|
[ drop index end ] ]
|
|
echoblum
|