How to resolve the algorithm Gapful numbers step by step in the Ring programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm Gapful numbers step by step in the Ring programming language
Table of Contents
Problem Statement
Numbers (positive integers expressed in base ten) that are (evenly) divisible by the number formed by the first and last digit are known as gapful numbers.
Evenly divisible means divisible with no remainder.
All one─ and two─digit numbers have this property and are trivially excluded. Only numbers ≥ 100 will be considered for this Rosetta Code task.
187 is a gapful number because it is evenly divisible by the number 17 which is formed by the first and last decimal digits of 187.
About 7.46% of positive integers are gapful.
Let's start with the solution:
Step by Step solution about How to resolve the algorithm Gapful numbers step by step in the Ring programming language
Source code in the ring programming language
nr = 0
gapful1 = 99
gapful2 = 999999
gapful3 = 999999999
limit1 = 30
limit2 = 15
limit3 = 10
see "First 30 gapful numbers >= 100:" + nl
while nr < limit1
gapful1 = gapful1 + 1
gap1 = left((string(gapful1)),1)
gap2 = right((string(gapful1)),1)
gap = number(gap1 +gap2)
if gapful1 % gap = 0
nr = nr + 1
see "" + nr + ". " + gapful1 + nl
ok
end
see nl
see "First 15 gapful numbers >= 1000000:" + nl
nr = 0
while nr < limit2
gapful2 = gapful2 + 1
gap1 = left((string(gapful2)),1)
gap2 = right((string(gapful2)),1)
gap = number(gap1 +gap2)
if (nr < limit2) and gapful2 % gap = 0
nr = nr + 1
see "" + nr + ". " + gapful2 + nl
ok
end
see nl
see "First 10 gapful numbers >= 1000000000:" + nl
nr = 0
while nr < limit3
gapful3 = gapful3 + 1
gap1 = left((string(gapful3)),1)
gap2 = right((string(gapful3)),1)
gap = number(gap1 +gap2)
if (nr < limit2) and gapful3 % gap = 0
nr = nr + 1
see "" + nr + ". " + gapful3 + nl
ok
end
You may also check:How to resolve the algorithm Convert seconds to compound duration step by step in the PL/I programming language
You may also check:How to resolve the algorithm Humble numbers step by step in the Pascal programming language
You may also check:How to resolve the algorithm Stirling numbers of the first kind step by step in the Go programming language
You may also check:How to resolve the algorithm Knapsack problem/Continuous step by step in the Ursala programming language
You may also check:How to resolve the algorithm Terminal control/Cursor positioning step by step in the PHP programming language