

Definition

An   eban   number is a number that has no letter    e    in it when the number is spelled in English.

Or more literally,   spelled numbers that contain the letter   e   are banned.



The American version of spelling numbers will be used here   (as opposed to the British).

2,000,000,000   is two billion,   not   two milliard.



Only numbers less than   one sextillion   (1021)   will be considered in/for this task.

This will allow optimizations to be used.



Task

   show all eban numbers   ≤   1,000   (in a horizontal format),   and a count
   show all eban numbers between   1,000   and   4,000   (inclusive),   and a count
   show a count of all eban numbers up and including           10,000
   show a count of all eban numbers up and including         100,000
   show a count of all eban numbers up and including      1,000,000
   show a count of all eban numbers up and including    10,000,000
   show all output here.


See also

   The MathWorld entry:   eban numbers.
   The OEIS entry:   A6933, eban numbers.


def main
    intervals = [
        [2, 1000, true],
        [1000, 4000, true],
        [2, 10000, false],
        [2, 100000, false],
        [2, 1000000, false],
        [2, 10000000, false],
        [2, 100000000, false],
        [2, 1000000000, false]
    ]
    for intv in intervals
        (start, ending, display) = intv
        if start == 2 then
            print "eban numbers up to and including %d:\n" % [ending]
        else
            print "eban numbers between %d and %d (inclusive):\n" % [start, ending]
        end
 
        count = 0
        for i in (start .. ending).step(2)
            b = (i / 1000000000).floor
            r = (i % 1000000000)
            m = (r / 1000000).floor
            r = (r % 1000000)
            t = (r / 1000).floor
            r = (r % 1000)
            if m >= 30 and m <= 66 then
                m = m % 10
            end
            if t >= 30 and t <= 66 then
                t = t % 10
            end
            if r >= 30 and r <= 66 then
                r = r % 10
            end
            if b == 0 or b == 2 or b == 4 or b == 6 then
                if m == 0 or m == 2 or m == 4 or m == 6 then
                    if t == 0 or t == 2 or t == 4 or t == 6 then
                        if r == 0 or r == 2 or r == 4 or r == 6 then
                            if display then
                                print ' ', i
                            end
                            count = count + 1
                        end
                    end
                end
            end
        end
        if display then
            print "\n"
        end
        print "count = %d\n\n" % [count]
    end
end
 
main()