How to resolve the algorithm Eban numbers step by step in the Yabasic programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm Eban numbers step by step in the Yabasic programming language

Table of Contents

Problem Statement

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.

Let's start with the solution:

Step by Step solution about How to resolve the algorithm Eban numbers step by step in the Yabasic programming language

Source code in the yabasic programming language

data 2, 100, true
data 1000, 4000, true
data 2, 1e4, false
data 2, 1e5, false
data 2, 1e6, false
data 2, 1e7, false
data 2, 1e8, false
REM data 2, 1e9, false  // it takes a lot of time
data 0, 0, false

do
    read start, ended, printable
    if not start break 
    
    if start = 2 then
        Print "eban numbers up to and including ", ended
    else
        Print "eban numbers between ", start, " and ", ended, " (inclusive):"
    endif
    count = 0
    for i = start to ended step 2
        b = int(i / 1000000000)
        r = mod(i, 1000000000)
        m = int(r / 1000000)
        r = mod(i, 1000000)
        t = int(r / 1000)
        r = mod(r, 1000)
        if m >= 30 and m <= 66 m = mod(m, 10)
        if t >= 30 and t <= 66 t = mod(t, 10)
        if r >= 30 and r <= 66 r = mod(r, 10)
        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 printable Print i;
                        count = count + 1
                    endif
                endif
            endif
        endif
    next
    if printable Print
    Print "count = ", count, "\n"
loop

  

You may also check:How to resolve the algorithm Create a file step by step in the Python programming language
You may also check:How to resolve the algorithm Sum of squares step by step in the PostScript programming language
You may also check:How to resolve the algorithm Calendar - for REAL programmers step by step in the PL/I programming language
You may also check:How to resolve the algorithm Almost prime step by step in the Groovy programming language
You may also check:How to resolve the algorithm Execute HQ9+ step by step in the PureBasic programming language