Eban numbers: Difference between revisions
Content added Content deleted
(Added Wren) |
|||
Line 1,897: | Line 1,897: | ||
eban numbers up to and including 1000000000: |
eban numbers up to and including 1000000000: |
||
count = 7999</pre> |
count = 7999</pre> |
||
=={{header|Wren}}== |
|||
{{trans|Go}} |
|||
<lang ecmascript>var rgs = [ |
|||
[2, 1000, true], |
|||
[1000, 4000, true], |
|||
[2, 1e4, false], |
|||
[2, 1e5, false], |
|||
[2, 1e6, false], |
|||
[2, 1e7, false], |
|||
[2, 1e8, false], |
|||
[2, 1e9, false] |
|||
] |
|||
for (rg in rgs) { |
|||
if (rg[0] == 2) { |
|||
System.print("eban numbers up to and including %(rg[1])") |
|||
} else { |
|||
System.print("eban numbers between %(rg[0]) and %(rg[1]) (inclusive):") |
|||
} |
|||
var count = 0 |
|||
var i = rg[0] |
|||
while (i <= rg[1]) { |
|||
var b = (i/1e9).floor |
|||
var r = i % 1e9 |
|||
var m = (r/1e6).floor |
|||
r = i % 1e6 |
|||
var t = (r/1000).floor |
|||
r = r % 1000 |
|||
if (m >= 30 && m <= 66) m = m % 10 |
|||
if (t >= 30 && t <= 66) t = t % 10 |
|||
if (r >= 30 && r <= 66) 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 (rg[2]) System.write("%(i) ") |
|||
count = count + 1 |
|||
} |
|||
} |
|||
} |
|||
} |
|||
i = i + 2 |
|||
} |
|||
if (rg[2]) System.print() |
|||
System.print("count = %(count)\n") |
|||
}</lang> |
|||
{{out}} |
|||
<pre> |
|||
eban numbers up to and including 1000 |
|||
2 4 6 30 32 34 36 40 42 44 46 50 52 54 56 60 62 64 66 |
|||
count = 19 |
|||
eban numbers between 1000 and 4000 (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 10000 |
|||
count = 79 |
|||
eban numbers up to and including 100000 |
|||
count = 399 |
|||
eban numbers up to and including 1000000 |
|||
count = 399 |
|||
eban numbers up to and including 10000000 |
|||
count = 1599 |
|||
eban numbers up to and including 100000000 |
|||
count = 7999 |
|||
eban numbers up to and including 1000000000 |
|||
count = 7999 |
|||
</pre> |
|||
=={{header|Yabasic}}== |
=={{header|Yabasic}}== |