Eban numbers: Difference between revisions
Content deleted Content added
m →{{header|Yabasic}}: added zkl header |
→{{header|zkl}}: added code |
||
Line 983: | Line 983: | ||
=={{header|zkl}}== |
=={{header|zkl}}== |
||
{{trans|Go}} |
|||
<lang zkl></lang> |
|||
<lang zkl>rgs:=T( T(2, 1_000, True), // (start,end,print) |
|||
<lang zkl></lang> |
|||
T(1_000, 4_000, True), |
|||
T(2, 1e4, False), |
|||
T(2, 1e5, False), |
|||
T(2, 1e6, False), |
|||
T(2, 1e7, False), |
|||
T(2, 1e8, False), // slow |
|||
T(2, 1e9, False), ); // very slow |
|||
foreach start,end,pr in (rgs){ |
|||
if(start==2) println("eban numbers up to and including %,d:".fmt(end)); |
|||
else println("eban numbers between %,d and %,d (inclusive):".fmt(start,end)); |
|||
count:=0; |
|||
foreach i in ([start..end,2]){ |
|||
b:=i/100_0000_000; |
|||
r:=i%1_000_000_000; |
|||
m:=r/1_000_000; |
|||
r:=i%1_000_000; |
|||
t:=r/1_000; |
|||
r=r%1_000; |
|||
if(30<=m<=66) m=m%10; |
|||
if(30<=t<=66) t=t%10; |
|||
if(30<=r<=66) r=r%10; |
|||
if(magic(b) and magic(m) and magic(t) and magic(r)){ |
|||
if(pr) print(i," "); |
|||
count+=1; |
|||
} |
|||
} |
|||
if(pr) println(); |
|||
println("count = %,d\n".fmt(count)); |
|||
} |
|||
fcn magic(z){ z.isEven and z<=6 }</lang> |
|||
{{out}} |
{{out}} |
||
<pre style="height:35ex"> |
|||
<pre> |
|||
eban numbers up to and including 1,000: |
|||
2 4 6 30 32 34 36 40 42 44 46 50 52 54 56 60 62 64 66 |
|||
count = 19 |
|||
eban numbers between 1,000 and 4,000 (inclusive): |
|||
2000 2002 2004 2006 2030 2032 2034 2036 2040 2042 2044 2046 2050 2052 2054 2056 2060 2062 2064 2066 4000 |
|||
count = 21 |
|||
eban numbers up to and including 10,000: |
|||
count = 79 |
|||
eban numbers up to and including 100,000: |
|||
count = 399 |
|||
eban numbers up to and including 1,000,000: |
|||
count = 399 |
|||
eban numbers up to and including 10,000,000: |
|||
count = 1,599 |
|||
eban numbers up to and including 100,000,000: |
|||
count = 7,999 |
|||
eban numbers up to and including 1,000,000,000: |
|||
count = 7,999 |
|||
</pre> |
</pre> |