How to resolve the algorithm Eban numbers step by step in the XPL0 programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm Eban numbers step by step in the XPL0 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 XPL0 programming language
Source code in the xpl0 programming language
include xpllib; \for Print
int Rgs, Rg, Count, I, B, R, M, T;
[Rgs:= [
[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 Rg:= 0 to 8-1 do
[if Rgs(Rg,0) = 2 then
Print("eban numbers up to and including %d\n", Rgs(Rg,1))
else
Print("eban numbers between %d and %d (inclusive):\n", Rgs(Rg,0), Rgs(Rg,1));
Count:= 0;
I:= Rgs(Rg,0);
while I <= Rgs(Rg,1) do
[B:= (I/1_000_000_000);
M:= rem(0) / 1_000_000;
T:= rem(0) / 1_000;
R:= rem(0);
if M >= 30 and M <= 66 then M:= rem(M/10);
if T >= 30 and T <= 66 then T:= rem(T/10);
if R >= 30 and R <= 66 then R:= rem(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 Rgs(Rg,2) then Print("%d ", I);
Count:= Count+1;
];
I:= I+2;
];
if Rgs(Rg,2) then CrLf(0);
Print("count = %d\n", Count);
];
]
You may also check:How to resolve the algorithm Bitmap/Bézier curves/Cubic step by step in the Julia programming language
You may also check:How to resolve the algorithm Bulls and cows step by step in the Nim programming language
You may also check:How to resolve the algorithm Monads/Maybe monad step by step in the Julia programming language
You may also check:How to resolve the algorithm Execute Brain step by step in the Factor programming language
You may also check:How to resolve the algorithm File size distribution step by step in the J programming language