Eban numbers: Difference between revisions

Content added Content deleted
m (syntax highlighting fixup automation)
Line 37: Line 37:
{{trans|Nim}}
{{trans|Nim}}


<lang 11l>F iseban(n)
<syntaxhighlight lang="11l">F iseban(n)
I n == 0
I n == 0
R 0B
R 0B
Line 64: Line 64:
I iseban(i)
I iseban(i)
count++
count++
print("\nNumber of eban numbers up to and including #8: #4".format(maxn, count))</lang>
print("\nNumber of eban numbers up to and including #8: #4".format(maxn, count))</syntaxhighlight>


{{out}}
{{out}}
Line 84: Line 84:


=={{header|AppleScript}}==
=={{header|AppleScript}}==
<lang applescript>(*
<syntaxhighlight lang="applescript">(*
Quickly generate all the (positive) eban numbers up to and including the
Quickly generate all the (positive) eban numbers up to and including the
specified end number, then lose those before the start number.
specified end number, then lose those before the start number.
Line 199: Line 199:
end runTask
end runTask


runTask()</lang>
runTask()</syntaxhighlight>


{{output}}
{{output}}
<lang applescript>"19 eban numbers between 0 and 1,000:
<syntaxhighlight lang="applescript">"19 eban numbers between 0 and 1,000:
2, 4, 6, 30, 32, 34, 36, 40, 42, 44, 46, 50, 52, 54, 56, 60, 62, 64, 66
2, 4, 6, 30, 32, 34, 36, 40, 42, 44, 46, 50, 52, 54, 56, 60, 62, 64, 66
21 between 1,000 and 4,000:
21 between 1,000 and 4,000:
Line 211: Line 211:
1599 up to and including 10,000,000
1599 up to and including 10,000,000
16 between 66,066,066,020 and 1,000,000,000,000:
16 between 66,066,066,020 and 1,000,000,000,000:
6.606606603E+10, 6.6066066032E+10, 6.6066066034E+10, 6.6066066036E+10, 6.606606604E+10, 6.6066066042E+10, 6.6066066044E+10, 6.6066066046E+10, 6.606606605E+10, 6.6066066052E+10, 6.6066066054E+10, 6.6066066056E+10, 6.606606606E+10, 6.6066066062E+10, 6.6066066064E+10, 6.6066066066E+10"</lang>
6.606606603E+10, 6.6066066032E+10, 6.6066066034E+10, 6.6066066036E+10, 6.606606604E+10, 6.6066066042E+10, 6.6066066044E+10, 6.6066066046E+10, 6.606606605E+10, 6.6066066052E+10, 6.6066066054E+10, 6.6066066056E+10, 6.606606606E+10, 6.6066066062E+10, 6.6066066064E+10, 6.6066066066E+10"</syntaxhighlight>


=={{header|AutoHotkey}}==
=={{header|AutoHotkey}}==
<lang AutoHotkey>eban_numbers(min, max, show:=0){
<syntaxhighlight lang="autohotkey">eban_numbers(min, max, show:=0){
counter := 0, output := ""
counter := 0, output := ""
i := min
i := min
Line 238: Line 238:
}
}
return min "-" max " : " output " Count = " counter
return min "-" max " : " output " Count = " counter
}</lang>
}</syntaxhighlight>
Examples:<lang AutoHotkey>MsgBox, 262144, , % eban_numbers(0, 1000, 1)
Examples:<syntaxhighlight lang="autohotkey">MsgBox, 262144, , % eban_numbers(0, 1000, 1)
MsgBox, 262144, , % eban_numbers(1000, 4000, 1)
MsgBox, 262144, , % eban_numbers(1000, 4000, 1)
MsgBox, 262144, , % eban_numbers(0, 10000)
MsgBox, 262144, , % eban_numbers(0, 10000)
MsgBox, 262144, , % eban_numbers(0, 100000)
MsgBox, 262144, , % eban_numbers(0, 100000)
MsgBox, 262144, , % eban_numbers(0, 1000000)
MsgBox, 262144, , % eban_numbers(0, 1000000)
MsgBox, 262144, , % eban_numbers(0, 100000000)</lang>
MsgBox, 262144, , % eban_numbers(0, 100000000)</syntaxhighlight>
{{out}}
{{out}}
<pre>2-1000 : 2 4 6 30 32 34 36 40 42 44 46 50 52 54 56 60 62 64 66 Count = 19
<pre>2-1000 : 2 4 6 30 32 34 36 40 42 44 46 50 52 54 56 60 62 64 66 Count = 19
Line 255: Line 255:


=={{header|AWK}}==
=={{header|AWK}}==
<syntaxhighlight lang="awk">
<lang AWK>
# syntax: GAWK -f EBAN_NUMBERS.AWK
# syntax: GAWK -f EBAN_NUMBERS.AWK
# converted from FreeBASIC
# converted from FreeBASIC
Line 292: Line 292:
return(n == 0 || n == 2 || n == 4 || n == 6)
return(n == 0 || n == 2 || n == 4 || n == 6)
}
}
</syntaxhighlight>
</lang>
{{out}}
{{out}}
<pre>
<pre>
Line 306: Line 306:
=={{header|C}}==
=={{header|C}}==
{{trans|D}}
{{trans|D}}
<lang c>#include "stdio.h"
<syntaxhighlight lang="c">#include "stdio.h"
#include "stdbool.h"
#include "stdbool.h"


Line 369: Line 369:


return 0;
return 0;
}</lang>
}</syntaxhighlight>
{{out}}
{{out}}
<pre>eban numbers up to and including 1000:
<pre>eban numbers up to and including 1000:
Line 398: Line 398:
=={{header|C sharp|C#}}==
=={{header|C sharp|C#}}==
{{trans|D}}
{{trans|D}}
<lang csharp>using System;
<syntaxhighlight lang="csharp">using System;


namespace EbanNumbers {
namespace EbanNumbers {
Line 460: Line 460:
}
}
}
}
}</lang>
}</syntaxhighlight>
{{out}}
{{out}}
<pre>eban numbers up to and including 1000:
<pre>eban numbers up to and including 1000:
Line 490: Line 490:
=={{header|C++}}==
=={{header|C++}}==
{{trans|D}}
{{trans|D}}
<lang cpp>#include <iostream>
<syntaxhighlight lang="cpp">#include <iostream>


struct Interval {
struct Interval {
Line 545: Line 545:


return 0;
return 0;
}</lang>
}</syntaxhighlight>
{{out}}
{{out}}
<pre>eban numbers up to and including 1000:
<pre>eban numbers up to and including 1000:
Line 574: Line 574:


=={{header|CLU}}==
=={{header|CLU}}==
<lang clu>eban = cluster is numbers
<syntaxhighlight lang="clu">eban = cluster is numbers
rep = null
rep = null
Line 667: Line 667:
if nextmagn>maxmagn then break end
if nextmagn>maxmagn then break end
end
end
end start_up </lang>
end start_up </syntaxhighlight>
{{out}}
{{out}}
<pre> 2 4 6 30 32 34 36 40 42 44 46 50 52 54 56 60 62 64 66
<pre> 2 4 6 30 32 34 36 40 42 44 46 50 52 54 56 60 62 64 66
Line 687: Line 687:
=={{header|D}}==
=={{header|D}}==
{{trans|Kotlin}}
{{trans|Kotlin}}
<lang d>import std.stdio;
<syntaxhighlight lang="d">import std.stdio;


struct Interval {
struct Interval {
Line 740: Line 740:
writeln;
writeln;
}
}
}</lang>
}</syntaxhighlight>
{{out}}
{{out}}
<pre>eban numbers up to an including 1000:
<pre>eban numbers up to an including 1000:
Line 770: Line 770:
=={{header|Factor}}==
=={{header|Factor}}==
{{trans|Julia}}
{{trans|Julia}}
<lang factor>USING: arrays formatting fry io kernel math math.functions
<syntaxhighlight lang="factor">USING: arrays formatting fry io kernel math math.functions
math.order math.ranges prettyprint sequences ;
math.order math.ranges prettyprint sequences ;


Line 784: Line 784:


1 1000 1000 4000 [ .eban-range ] 2bi@
1 1000 1000 4000 [ .eban-range ] 2bi@
4 9 [a,b] [ [ 1 10 ] dip ^ .eban-count ] each</lang>
4 9 [a,b] [ [ 1 10 ] dip ^ .eban-count ] each</syntaxhighlight>
{{out}}
{{out}}
<pre>
<pre>
Line 798: Line 798:


=={{header|FreeBASIC}}==
=={{header|FreeBASIC}}==
<lang freebasic>
<syntaxhighlight lang="freebasic">
' Eban_numbers
' Eban_numbers
' Un número eban es un número que no tiene la letra e cuando el número está escrito en inglés.
' Un número eban es un número que no tiene la letra e cuando el número está escrito en inglés.
Line 857: Line 857:
Print "Run time: " & (tiempo) & " seconds."
Print "Run time: " & (tiempo) & " seconds."
End
End
</syntaxhighlight>
</lang>
{{out}}
{{out}}
<pre>
<pre>
Line 895: Line 895:


=={{header|Go}}==
=={{header|Go}}==
<lang go>package main
<syntaxhighlight lang="go">package main


import "fmt"
import "fmt"
Line 956: Line 956:
fmt.Println("count =", count, "\n")
fmt.Println("count =", count, "\n")
}
}
}</lang>
}</syntaxhighlight>


{{out}}
{{out}}
Line 989: Line 989:
=={{header|Groovy}}==
=={{header|Groovy}}==
{{trans|Java}}
{{trans|Java}}
<lang groovy>class Main {
<syntaxhighlight lang="groovy">class Main {
private static class Range {
private static class Range {
int start
int start
Line 1,050: Line 1,050:
}
}
}
}
}</lang>
}</syntaxhighlight>
{{out}}
{{out}}
<pre>Same as the Java entry</pre>
<pre>Same as the Java entry</pre>
Line 1,056: Line 1,056:
=={{header|Haskell}}==
=={{header|Haskell}}==
{{trans|Julia}}
{{trans|Julia}}
<lang haskell>{-# LANGUAGE NumericUnderscores #-}
<syntaxhighlight lang="haskell">{-# LANGUAGE NumericUnderscores #-}
import Data.List (intercalate)
import Data.List (intercalate)
import Text.Printf (printf)
import Text.Printf (printf)
Line 1,088: Line 1,088:
, 100_000_000
, 100_000_000
, 1_000_000_000 ]
, 1_000_000_000 ]
r = ((,) <$> thousands . length <*> show) . filter isEban</lang>
r = ((,) <$> thousands . length <*> show) . filter isEban</syntaxhighlight>
{{out}}
{{out}}
<pre>
<pre>
Line 1,106: Line 1,106:


=={{header|J}}==
=={{header|J}}==
<syntaxhighlight lang="j">
<lang J>
Filter =: (#~`)(`:6)
Filter =: (#~`)(`:6)


Line 1,131: Line 1,131:
1e6 399
1e6 399
1e7 1599
1e7 1599
</syntaxhighlight>
</lang>


=={{header|Java}}==
=={{header|Java}}==
{{trans|Kotlin}}
{{trans|Kotlin}}
<lang java>import java.util.List;
<syntaxhighlight lang="java">import java.util.List;


public class Main {
public class Main {
Line 1,195: Line 1,195:
}
}
}
}
}</lang>
}</syntaxhighlight>
{{out}}
{{out}}
<pre>eban numbers up to and including 1000
<pre>eban numbers up to and including 1000
Line 1,231: Line 1,231:
completion of the task beyond 1E+7; the output shown below was
completion of the task beyond 1E+7; the output shown below was
obtained using the C implementation of jq.
obtained using the C implementation of jq.
<lang jq># quotient and remainder
<syntaxhighlight lang="jq"># quotient and remainder
def quotient($a; $b; f; g): f = (($a/$b)|floor) | g = $a % $b;
def quotient($a; $b; f; g): f = (($a/$b)|floor) | g = $a % $b;


Line 1,263: Line 1,263:
if .total then "count = \(.count)\n" else empty end) );
if .total then "count = \(.count)\n" else empty end) );


task</lang>
task</syntaxhighlight>
{{out}}
{{out}}
<pre>
<pre>
Line 1,328: Line 1,328:
</pre>
</pre>
=={{header|Julia}}==
=={{header|Julia}}==
<syntaxhighlight lang="julia">
<lang Julia>
function iseban(n::Integer)
function iseban(n::Integer)
b, r = divrem(n, oftype(n, 10 ^ 9))
b, r = divrem(n, oftype(n, 10 ^ 9))
Line 1,349: Line 1,349:
println("eban numbers up to and including 100000000: ", count(iseban, 1:100000000))
println("eban numbers up to and including 100000000: ", count(iseban, 1:100000000))
println("eban numbers up to and including 1000000000: ", count(iseban, 1:1000000000))
println("eban numbers up to and including 1000000000: ", count(iseban, 1:1000000000))
</syntaxhighlight>
</lang>


{{out}}
{{out}}
Line 1,365: Line 1,365:
=={{header|Kotlin}}==
=={{header|Kotlin}}==
{{trans|Go}}
{{trans|Go}}
<lang scala>// Version 1.3.21
<syntaxhighlight lang="scala">// Version 1.3.21


typealias Range = Triple<Int, Int, Boolean>
typealias Range = Triple<Int, Int, Boolean>
Line 1,412: Line 1,412:
println("count = $count\n")
println("count = $count\n")
}
}
}</lang>
}</syntaxhighlight>


{{output}}
{{output}}
Line 1,421: Line 1,421:
=={{header|Lua}}==
=={{header|Lua}}==
{{trans|lang}}
{{trans|lang}}
<lang lua>function makeInterval(s,e,p)
<syntaxhighlight lang="lua">function makeInterval(s,e,p)
return {start=s, end_=e, print_=p}
return {start=s, end_=e, print_=p}
end
end
Line 1,473: Line 1,473:
end
end


main()</lang>
main()</syntaxhighlight>
{{out}}
{{out}}
<pre>eban numbers up to and including 1000:
<pre>eban numbers up to and including 1000:
Line 1,499: Line 1,499:


=={{header|Mathematica}}/{{header|Wolfram Language}}==
=={{header|Mathematica}}/{{header|Wolfram Language}}==
<lang Mathematica>ClearAll[ZeroTwoFourSixQ, EbanNumbers]
<syntaxhighlight lang="mathematica">ClearAll[ZeroTwoFourSixQ, EbanNumbers]
ZeroTwoFourSixQ[n_Integer] := (n == 0 || n == 2 || n == 4 || n == 6)
ZeroTwoFourSixQ[n_Integer] := (n == 0 || n == 2 || n == 4 || n == 6)
EbanNumbers[min_, max_, show : (False | True)] :=
EbanNumbers[min_, max_, show : (False | True)] :=
Line 1,534: Line 1,534:
EbanNumbers[0, 10^5, False]
EbanNumbers[0, 10^5, False]
EbanNumbers[0, 10^6, False]
EbanNumbers[0, 10^6, False]
EbanNumbers[0, 10^7, False]</lang>
EbanNumbers[0, 10^7, False]</syntaxhighlight>
{{out}}
{{out}}
<pre>0-1000: 2 4 6 30 32 34 36 40 42 44 46 50 52 54 56 60 62 64 66 count = 19
<pre>0-1000: 2 4 6 30 32 34 36 40 42 44 46 50 52 54 56 60 62 64 66 count = 19
Line 1,546: Line 1,546:
===Exhaustive search===
===Exhaustive search===
{{trans|Julia}}
{{trans|Julia}}
<lang nim>import strformat
<syntaxhighlight lang="nim">import strformat


proc iseban(n: int): bool =
proc iseban(n: int): bool =
Line 1,600: Line 1,600:
if iseban(i):
if iseban(i):
inc count
inc count
echo &"\nNumber of eban numbers up to and including {100000000:8}: {count:4}"</lang>
echo &"\nNumber of eban numbers up to and including {100000000:8}: {count:4}"</syntaxhighlight>


{{out}}
{{out}}
Line 1,621: Line 1,621:
===Algorithmic computation===
===Algorithmic computation===
{{trans|Phix}}
{{trans|Phix}}
<lang Nim>import math, strutils, strformat
<syntaxhighlight lang="nim">import math, strutils, strformat


#---------------------------------------------------------------------------------------------------
#---------------------------------------------------------------------------------------------------
Line 1,664: Line 1,664:
echo fmt"ebanCount(10^{i}): {ebanCount(i)}"
echo fmt"ebanCount(10^{i}): {ebanCount(i)}"
echo ""
echo ""
echo fmt"Time: {getTime() - t0}"</lang>
echo fmt"Time: {getTime() - t0}"</syntaxhighlight>


{{out}}
{{out}}
Line 1,697: Line 1,697:
===Exhaustive search===
===Exhaustive search===
A couple of 'e'-specific optimizations keep the running time reasonable.
A couple of 'e'-specific optimizations keep the running time reasonable.
<lang perl>use strict;
<syntaxhighlight lang="perl">use strict;
use warnings;
use warnings;
use feature 'say';
use feature 'say';
Line 1,730: Line 1,730:
my $n = + grep { $_ <= 10**$exp } @OK;
my $n = + grep { $_ <= 10**$exp } @OK;
printf "Number of eban numbers and %10s: %d\n", comma(10**$exp), $n;
printf "Number of eban numbers and %10s: %d\n", comma(10**$exp), $n;
}</lang>
}</syntaxhighlight>
{{out}}
{{out}}
<pre>eban numbers up to and including 1000:
<pre>eban numbers up to and including 1000:
Line 1,746: Line 1,746:
Alternately, a partial translation of Raku. Does not need to actually generate the e-ban numbers to count them. Display counts up to 10**21.
Alternately, a partial translation of Raku. Does not need to actually generate the e-ban numbers to count them. Display counts up to 10**21.


<lang perl>use strict;
<syntaxhighlight lang="perl">use strict;
use warnings;
use warnings;
use bigint;
use bigint;
Line 1,821: Line 1,821:
printf "Up to and including %23s: %s\n", lc(num2word(10**$exp)), comma($nu);
printf "Up to and including %23s: %s\n", lc(num2word(10**$exp)), comma($nu);
}
}
}</lang>
}</syntaxhighlight>
<pre>============= e-ban: =============
<pre>============= e-ban: =============
e-ban numbers up to 1000: 19
e-ban numbers up to 1000: 19
Line 1,854: Line 1,854:
=={{header|Phix}}==
=={{header|Phix}}==
Why count when you can calculate?
Why count when you can calculate?
<!--<lang Phix>(phixonline)-->
<!--<syntaxhighlight lang="phix">(phixonline)-->
<span style="color: #008080;">with</span> <span style="color: #008080;">javascript_semantics</span>
<span style="color: #008080;">with</span> <span style="color: #008080;">javascript_semantics</span>
<span style="color: #008080;">function</span> <span style="color: #000000;">count_eban</span><span style="color: #0000FF;">(</span><span style="color: #004080;">integer</span> <span style="color: #000000;">p10</span><span style="color: #0000FF;">)</span>
<span style="color: #008080;">function</span> <span style="color: #000000;">count_eban</span><span style="color: #0000FF;">(</span><span style="color: #004080;">integer</span> <span style="color: #000000;">p10</span><span style="color: #0000FF;">)</span>
Line 1,893: Line 1,893:
<span style="color: #008080;">end</span> <span style="color: #008080;">for</span>
<span style="color: #008080;">end</span> <span style="color: #008080;">for</span>
<span style="color: #0000FF;">?</span><span style="color: #7060A8;">elapsed</span><span style="color: #0000FF;">(</span><span style="color: #7060A8;">time</span><span style="color: #0000FF;">()-</span><span style="color: #000000;">t0</span><span style="color: #0000FF;">)</span>
<span style="color: #0000FF;">?</span><span style="color: #7060A8;">elapsed</span><span style="color: #0000FF;">(</span><span style="color: #7060A8;">time</span><span style="color: #0000FF;">()-</span><span style="color: #000000;">t0</span><span style="color: #0000FF;">)</span>
<!--</lang>-->
<!--</syntaxhighlight>-->
{{out}}
{{out}}
<pre>
<pre>
Line 1,926: Line 1,926:


=={{header|PicoLisp}}==
=={{header|PicoLisp}}==
<lang PicoLisp>(de _eban? (N)
<syntaxhighlight lang="picolisp">(de _eban? (N)
(let
(let
(B (/ N 1000000000)
(B (/ N 1000000000)
Line 1,982: Line 1,982:
(prinl)
(prinl)
(prinl "eban numbers up to an including 10000000:")
(prinl "eban numbers up to an including 10000000:")
(prinl "count: " (car (eban 10000000)))</lang>
(prinl "count: " (car (eban 10000000)))</syntaxhighlight>
{{out}}
{{out}}
<pre>
<pre>
Line 2,007: Line 2,007:


=={{header|Python}}==
=={{header|Python}}==
<syntaxhighlight lang="python">
<lang Python>
# Use inflect
# Use inflect


Line 2,132: Line 2,132:
print(" ")
print(" ")
print("Run time in seconds: "+str(after - before))
print("Run time in seconds: "+str(after - before))
</syntaxhighlight>
</lang>


Output:
Output:
Line 2,200: Line 2,200:
Considering numbers up to <strong>10<sup>21</sup></strong>, as the task directions suggest.
Considering numbers up to <strong>10<sup>21</sup></strong>, as the task directions suggest.


<lang perl6>use Lingua::EN::Numbers;
<syntaxhighlight lang="raku" line>use Lingua::EN::Numbers;


sub nban ($seq, $n = 'e') { ($seq).map: { next if .&cardinal.contains(any($n.lc.comb)); $_ } }
sub nban ($seq, $n = 'e') { ($seq).map: { next if .&cardinal.contains(any($n.lc.comb)); $_ } }
Line 2,271: Line 2,271:
printf "Up to and including %{$s}s: %s\n", cardinal(10**($c+1)), comma(@counts[$c]);
printf "Up to and including %{$s}s: %s\n", cardinal(10**($c+1)), comma(@counts[$c]);
}
}
}</lang>
}</syntaxhighlight>
{{out}}
{{out}}
<pre>============= e-ban: =============
<pre>============= e-ban: =============
Line 2,372: Line 2,372:
=={{header|REXX}}==
=={{header|REXX}}==
Programming note: &nbsp; REXX has no shortcuts for &nbsp; '''if''' &nbsp; statements, so the multiple &nbsp; '''if''' &nbsp; statements weren't combined into one.
Programming note: &nbsp; REXX has no shortcuts for &nbsp; '''if''' &nbsp; statements, so the multiple &nbsp; '''if''' &nbsp; statements weren't combined into one.
<lang rexx>/*REXX program to display eban numbers (those that don't have an "e" their English name)*/
<syntaxhighlight lang="rexx">/*REXX program to display eban numbers (those that don't have an "e" their English name)*/
numeric digits 20 /*support some gihugic numbers for pgm.*/
numeric digits 20 /*support some gihugic numbers for pgm.*/
parse arg $ /*obtain optional arguments from the cL*/
parse arg $ /*obtain optional arguments from the cL*/
Line 2,409: Line 2,409:
if hun\==' ' then return 1 /*any hundrEd (not zero) has an "e". */
if hun\==' ' then return 1 /*any hundrEd (not zero) has an "e". */
end /*k*/ /*A "period" is a group of 3 dec. digs */
end /*k*/ /*A "period" is a group of 3 dec. digs */
return 0 /*in the number, grouped from the right*/</lang>
return 0 /*in the number, grouped from the right*/</syntaxhighlight>
{{out|output|text=&nbsp; when using the default inputs:}}
{{out|output|text=&nbsp; when using the default inputs:}}
<pre>
<pre>
Line 2,436: Line 2,436:
=={{header|Ruby}}==
=={{header|Ruby}}==
{{trans|C#}}
{{trans|C#}}
<lang ruby>def main
<syntaxhighlight lang="ruby">def main
intervals = [
intervals = [
[2, 1000, true],
[2, 1000, true],
Line 2,492: Line 2,492:
end
end


main()</lang>
main()</syntaxhighlight>
{{out}}
{{out}}
<pre>eban numbers up to and including 1000:
<pre>eban numbers up to and including 1000:
Line 2,522: Line 2,522:
=={{header|Scala}}==
=={{header|Scala}}==
{{trans|Java}}
{{trans|Java}}
<lang scala>object EbanNumbers {
<syntaxhighlight lang="scala">object EbanNumbers {


class ERange(s: Int, e: Int, p: Boolean) {
class ERange(s: Int, e: Int, p: Boolean) {
Line 2,585: Line 2,585:
}
}
}
}
}</lang>
}</syntaxhighlight>
{{out}}
{{out}}
<pre>eban numbers up to an including 1000
<pre>eban numbers up to an including 1000
Line 2,614: Line 2,614:


=={{header|Tailspin}}==
=={{header|Tailspin}}==
<lang tailspin>
<syntaxhighlight lang="tailspin">
templates isEban
templates isEban
def number: $;
def number: $;
'$;' -> \(<'([246]|[3456][0246])(0[03456][0246])*'> $ !\) -> $number !
'$;' -> \(<'([246]|[3456][0246])(0[03456][0246])*'> $ !\) -> $number !
end isEban
end isEban
</syntaxhighlight>
</lang>


Alternatively, if regex is not your thing, we can do it numerically, which actually runs faster
Alternatively, if regex is not your thing, we can do it numerically, which actually runs faster
<lang tailspin>
<syntaxhighlight lang="tailspin">
templates isEban
templates isEban
def number: $;
def number: $;
Line 2,629: Line 2,629:
when <?($ mod 1000 <=0|=2|=4|=6|30..66?($ mod 10 <=0|=2|=4|=6>)>)> do $ ~/ 1000 -> #
when <?($ mod 1000 <=0|=2|=4|=6|30..66?($ mod 10 <=0|=2|=4|=6>)>)> do $ ~/ 1000 -> #
end isEban
end isEban
</syntaxhighlight>
</lang>


Either version is called by the following code
Either version is called by the following code
<lang tailspin>
<syntaxhighlight lang="tailspin">
def small: [1..1000 -> isEban];
def small: [1..1000 -> isEban];
$small -> !OUT::write
$small -> !OUT::write
Line 2,662: Line 2,662:


' -> !OUT::write
' -> !OUT::write
</syntaxhighlight>
</lang>
{{out}}
{{out}}
<pre>
<pre>
Line 2,686: Line 2,686:
=={{header|Visual Basic .NET}}==
=={{header|Visual Basic .NET}}==
{{trans|D}}
{{trans|D}}
<lang vbnet>Module Module1
<syntaxhighlight lang="vbnet">Module Module1


Structure Interval
Structure Interval
Line 2,756: Line 2,756:
End Sub
End Sub


End Module</lang>
End Module</syntaxhighlight>
{{out}}
{{out}}
<pre>eban numbers up to and including 1000:
<pre>eban numbers up to and including 1000:
Line 2,786: Line 2,786:
=={{header|Vlang}}==
=={{header|Vlang}}==
{{trans|go}}
{{trans|go}}
<lang vlang>struct Range {
<syntaxhighlight lang="vlang">struct Range {
start i64
start i64
end i64
end i64
Line 2,843: Line 2,843:
println("count = $count\n")
println("count = $count\n")
}
}
}</lang>
}</syntaxhighlight>


{{out}}
{{out}}
Line 2,876: Line 2,876:
=={{header|Wren}}==
=={{header|Wren}}==
{{trans|Go}}
{{trans|Go}}
<lang ecmascript>var rgs = [
<syntaxhighlight lang="ecmascript">var rgs = [
[2, 1000, true],
[2, 1000, true],
[1000, 4000, true],
[1000, 4000, true],
Line 2,918: Line 2,918:
if (rg[2]) System.print()
if (rg[2]) System.print()
System.print("count = %(count)\n")
System.print("count = %(count)\n")
}</lang>
}</syntaxhighlight>


{{out}}
{{out}}
Line 2,951: Line 2,951:
=={{header|Yabasic}}==
=={{header|Yabasic}}==
{{trans|Go}}
{{trans|Go}}
<lang Yabasic>data 2, 100, true
<syntaxhighlight lang="yabasic">data 2, 100, true
data 1000, 4000, true
data 1000, 4000, true
data 2, 1e4, false
data 2, 1e4, false
Line 2,994: Line 2,994:
if printable Print
if printable Print
Print "count = ", count, "\n"
Print "count = ", count, "\n"
loop</lang>
loop</syntaxhighlight>


=={{header|zkl}}==
=={{header|zkl}}==
{{trans|Go}}
{{trans|Go}}
<lang zkl>rgs:=T( T(2, 1_000, True), // (start,end,print)
<syntaxhighlight lang="zkl">rgs:=T( T(2, 1_000, True), // (start,end,print)
T(1_000, 4_000, True),
T(1_000, 4_000, True),
T(2, 1e4, False), T(2, 1e5, False), T(2, 1e6, False), T(2, 1e7, False),
T(2, 1e4, False), T(2, 1e5, False), T(2, 1e6, False), T(2, 1e7, False),
Line 3,025: Line 3,025:
println("count = %,d\n".fmt(count));
println("count = %,d\n".fmt(count));
}
}
fcn magic(z){ z.isEven and z<=6 }</lang>
fcn magic(z){ z.isEven and z<=6 }</syntaxhighlight>
{{out}}
{{out}}
<pre style="height:35ex">
<pre style="height:35ex">