50 lines
1.1 KiB
Plaintext
50 lines
1.1 KiB
Plaintext
include "NSLog.incl"
|
|
_max = 2050000000
|
|
byte primes(_max / 16), x, y
|
|
uint64 trans(2, 9, 9)
|
|
|
|
clear local fn transitions
|
|
uint64 n = 3, count = 1, tgt = 10000, i
|
|
int a = 2, b, f = 3
|
|
|
|
while f
|
|
if primes(n >> 4) & bit((n & 15) >> 1) then n += 2 : continue
|
|
count ++
|
|
b = n mod 10
|
|
trans(0, a, b) ++
|
|
a = b
|
|
|
|
i = n * n
|
|
while i < _max
|
|
primes( i >> 4 ) |= bit((i & 15) >> 1)
|
|
i += (n << 1)
|
|
wend
|
|
|
|
n += 2
|
|
|
|
if count == tgt
|
|
f--
|
|
fn blockmove(@trans(0, 0, 0), @trans((f), 0, 0), 800) // store current results
|
|
tgt *= 100
|
|
end if
|
|
|
|
wend
|
|
|
|
nslog( @"\n\t# of Primes: 10,000 1,000,000 100,000,000")
|
|
CFStringRef s = @"%5d —> %d: %.2f%% %.2f%% %.2f%%"
|
|
for x = 1 to 9
|
|
for y = 1 to 9 //step 2
|
|
if trans(0,x, y) then nslog( s, x, y, trans(2, x, y)\100, trans(1, x, y)\100^2, trans(0, x, y)\100^3)
|
|
next
|
|
next
|
|
|
|
end fn
|
|
|
|
nsLogSetTitle(@"Last digits of one prime to the next")
|
|
//nsLogSetFrame(fn NSMakeRect( 0,0,400,350))
|
|
CFTimeInterval t : t = fn CACurrentMediaTime
|
|
fn transitions
|
|
nslog( @"\n %.3f sec.",(fn CACurrentMediaTime - t))
|
|
|
|
handleevents
|