51 lines
1.4 KiB
Plaintext
51 lines
1.4 KiB
Plaintext
void local fn Eban( start as NSUInteger, finish as NSUInteger, printable as BOOL )
|
|
NSUInteger i, b, r, m, t, count
|
|
|
|
if ( start = 2 )
|
|
printf @"eban numbers up to and including %lu", finish
|
|
else
|
|
printf @"eban numbers between %lu and %lu:", start, finish
|
|
end if
|
|
|
|
count = 0
|
|
for i = start to finish step 2
|
|
b = int(i / 100000000)
|
|
r = i % 100000000
|
|
m = int(r / 1000000)
|
|
r = i % 1000000
|
|
t = int(r / 1000)
|
|
r = r % 1000
|
|
if m >= 30 && m <= 66 then m = (m % 10)
|
|
if t >= 30 && t <= 66 then t = (t % 10)
|
|
if r >= 30 && r <= 66 then r = (r % 10)
|
|
if b = 0 || b = 2 || b = 4 || b = 6
|
|
if m = 0 || m = 2 || m = 4 || m = 6
|
|
if t = 0 || t = 2 || t = 4 || t = 6
|
|
if r = 0 || r = 2 || r = 4 || r = 6
|
|
if printable == YES then printf @"%lu \b", i
|
|
count++
|
|
end if
|
|
end if
|
|
end if
|
|
end if
|
|
next
|
|
if printable == YES then print
|
|
printf @"%lu eban numbers found\n", count
|
|
end fn
|
|
|
|
void local fn EbanNumbers
|
|
CFTimeInterval t = fn CACurrentMediaTime
|
|
fn Eban( 2, 1000, YES )
|
|
fn Eban( 1000, 4000, YES )
|
|
fn Eban( 2, 10000, NO )
|
|
fn Eban( 2, 100000, NO )
|
|
fn Eban( 2, 1000000, NO )
|
|
fn Eban( 2, 10000000, NO )
|
|
fn Eban( 2, 100000000, NO )
|
|
printf @"Compute time: %.3f sec\n", fn CACurrentMediaTime - t
|
|
end fn
|
|
|
|
fn EbanNumbers
|
|
|
|
HandleEvents
|