Gapful numbers: Difference between revisions
Content added Content deleted
(Ada version) |
(Added XPL0 example.) |
||
Line 3,481: | Line 3,481: | ||
First 15 gapful ints at 1000000: 1000000, 1000005, 1000008, 1000010, 1000016, 1000020, 1000021, 1000030, 1000032, 1000034, 1000035, 1000040, 1000050, 1000060, 1000065 |
First 15 gapful ints at 1000000: 1000000, 1000005, 1000008, 1000010, 1000016, 1000020, 1000021, 1000030, 1000032, 1000034, 1000035, 1000040, 1000050, 1000060, 1000065 |
||
First 15 gapful ints at 1000000000: 1000000000, 1000000001, 1000000005, 1000000008, 1000000010, 1000000016, 1000000020, 1000000027, 1000000030, 1000000032, 1000000035, 1000000039, 1000000040, 1000000050, 1000000053 |
First 15 gapful ints at 1000000000: 1000000000, 1000000001, 1000000005, 1000000008, 1000000010, 1000000016, 1000000020, 1000000027, 1000000030, 1000000032, 1000000035, 1000000039, 1000000040, 1000000050, 1000000053 |
||
</pre> |
|||
=={{header|XPL0}}== |
|||
<lang XPL0>func Gapful(N0); \Return 'true' if gapful number |
|||
int N0, N, First, Last; |
|||
[N:= N0; |
|||
N:= N/10; |
|||
Last:= rem(0); |
|||
repeat N:= N/10; |
|||
First:= rem(0); |
|||
until N = 0; |
|||
N:= First*10 + Last; |
|||
return rem(N0/N) = 0; |
|||
]; |
|||
proc ShowGap(Start, Limit); \Display gapful numbers |
|||
int Start, Limit, Count, N; |
|||
[Text(0, "First "); IntOut(0, Limit); Text(0, " gapful numbers starting from "); |
|||
IntOut(0, Start); Text(0, ":^m^j"); |
|||
Count:= 0; N:= Start; |
|||
loop [if Gapful(N) then |
|||
[IntOut(0, N); ChOut(0, ^ ); |
|||
Count:= Count+1; |
|||
if Count >= Limit then quit; |
|||
]; |
|||
N:= N+1; |
|||
]; |
|||
CrLf(0); |
|||
]; |
|||
[ShowGap(100, 30); |
|||
ShowGap(1_000_000, 15); |
|||
ShowGap(1_000_000_000, 10); |
|||
]</lang> |
|||
{{out}} |
|||
<pre> |
|||
First 30 gapful numbers starting from 100: |
|||
100 105 108 110 120 121 130 132 135 140 143 150 154 160 165 170 176 180 187 190 192 195 198 200 220 225 231 240 242 253 |
|||
First 15 gapful numbers starting from 1000000: |
|||
1000000 1000005 1000008 1000010 1000016 1000020 1000021 1000030 1000032 1000034 1000035 1000040 1000050 1000060 1000065 |
|||
First 10 gapful numbers starting from 1000000000: |
|||
1000000000 1000000001 1000000005 1000000008 1000000010 1000000016 1000000020 1000000027 1000000030 1000000032 |
|||
</pre> |
</pre> |
||