Forbidden numbers: Difference between revisions

Added Sidef
(Added FreeBasic)
(Added Sidef)
 
(14 intermediate revisions by 12 users not shown)
Line 86:
There are 8333330 Forbidden numbers up to 50000000
</pre>
 
=={{header|AppleScript}}==
{{trans|Phix}}
<syntaxhighlight lang="applescript">on isForbidden(n)
repeat while ((n mod 4 = 0) and (n > 7))
set n to n div 4
end repeat
return (n mod 8 = 7)
end isForbidden
 
on forbiddenCount(limit)
set {counter, p4, n} to {0, 1, 7}
repeat while (n ≤ limit)
set p4 to p4 * 4
set counter to counter + (limit - n) div (p4 + p4) + 1
set n to p4 * 7
end repeat
return counter
end forbiddenCount
 
on join(lst, delim)
set astid to AppleScript's text item delimiters
set AppleScript's text item delimiters to delim
set txt to lst as text
set AppleScript's text item delimiters to astid
return txt
end join
 
on intToText(int, separator)
set groups to {}
repeat while (int > 999)
set groups's beginning to ((1000 + (int mod 1000 as integer)) as text)'s text 2 thru 4
set int to int div 1000
end repeat
set groups's beginning to int as integer
return join(groups, separator)
end intToText
 
on task()
set output to {"First fifty forbidden numbers:"}
set {counter, n, row} to {0, 0, {}}
repeat until (counter = 50)
set n to n + 1
if (isForbidden(n)) then
set counter to counter + 1
set row's end to (" " & n)'s text -4 thru -1
if (counter mod 10 = 0) then
set output's end to join(row, "")
set row to {}
end if
end if
end repeat
set output's end to row
repeat with target in {500, 5000, 50000, 500000, 5000000, 50000000, 500000000}
set output's end to intToText(forbiddenCount(target), ",") & ¬
" forbidden numbers ≤ " & intToText(target, ",")
end repeat
return join(output, linefeed)
end task
 
task()</syntaxhighlight>
 
{{output}}
<syntaxhighlight lang="applescript">"First fifty forbidden numbers:
7 15 23 28 31 39 47 55 60 63
71 79 87 92 95 103 111 112 119 124
127 135 143 151 156 159 167 175 183 188
191 199 207 215 220 223 231 239 240 247
252 255 263 271 279 284 287 295 303 311
 
82 forbidden numbers ≤ 500
831 forbidden numbers ≤ 5,000
8,330 forbidden numbers ≤ 50,000
83,331 forbidden numbers ≤ 500,000
833,329 forbidden numbers ≤ 5,000,000
8,333,330 forbidden numbers ≤ 50,000,000
83,333,328 forbidden numbers ≤ 500,000,000"</syntaxhighlight>
 
=={{header|Arturo}}==
 
<syntaxhighlight lang="arturo">forbidden?: function [n][
m: new n
v: 0
while -> and? m > 1 0 = m % 4 [
'm / 4
inc 'v
]
7 = mod n / 4 ^ v 8
]
 
print "First 50 forbidden numbers:"
forbidden: split.every:10 select.first:50 0..∞ => forbidden?
loop forbidden 'row [
loop row 'n -> prints pad ~"|n|" 4
print ""
]
 
print ""
[target n count]: [500 0 0]
while -> target =< 5e6 [
if forbidden? n -> inc 'count
if n = target [
print [count "forbidden numbers up to" target]
'target * 10
]
inc 'n
]</syntaxhighlight>
 
{{out}}
 
<pre>First 50 forbidden numbers:
7 15 23 28 31 39 47 55 60 63
71 79 87 92 95 103 111 112 119 124
127 135 143 151 156 159 167 175 183 188
191 199 207 215 220 223 231 239 240 247
252 255 263 271 279 284 287 295 303 311
 
82 forbidden numbers up to 500
831 forbidden numbers up to 5000
8330 forbidden numbers up to 50000
83331 forbidden numbers up to 500000
833329 forbidden numbers up to 5000000</pre>
 
=={{header|C}}==
Line 235 ⟶ 359:
Forbidden number count <= 500,000,000: 83,333,328
</pre>
 
=={{header|J}}==
 
For this task we can find forbidden numbers up to some limiting value y:
<syntaxhighlight lang=J>forbid=: {{
s1=. *:i.1+<.%:y
s2=. ~.(#~ y>:]),s1+/s1
s3=. ~.(#~ y>:]),s2+/s1
(1+i.y)-.s1,s2,s3
}}</syntaxhighlight>
 
In other words: <code>s1</code> is square numbers up through y, <code>s2</code> is unique sums of those squares up through y, <code>s3</code> is unique sums of members of those two sequences, up through y, and our result is numbers up through y which do not appear in <code>s1</code>, <code>s2</code> or <code>s3</code>.
 
The task then becomes:
 
<syntaxhighlight lang=J> 5 10$forbid 500
7 15 23 28 31 39 47 55 60 63
71 79 87 92 95 103 111 112 119 124
127 135 143 151 156 159 167 175 183 188
191 199 207 215 220 223 231 239 240 247
252 255 263 271 279 284 287 295 303 311
#forbid 500
82
#forbid 5000
831
#forbid 50000
8330
#forbid 500000
83331</syntaxhighlight>
 
=={{header|jq}}==
Line 289 ⟶ 442:
 
Forbidden number count up to 500000: 83331
</pre>
 
=={{header|Julia}}==
{{trans|Python}}
<syntaxhighlight lang ="python">""" true if num is a forbidden number """
function isforbidden(num)
fours, pow4 = num, 0
while fours > 1 && fours % 4 == 0
fours ÷= 4
pow4 += 1
end
return (num ÷ 4^pow4) % 8 == 7
end
 
const f500M = filter(isforbidden, 1:500_000_000)
 
for (idx, fbd) in enumerate(f500M[begin:begin+49])
print(lpad(fbd, 4), idx % 10 == 0 ? '\n' : "")
end
 
for fbmax in [500, 5000, 50_000, 500_000, 500_000_000]
println("\nThere are $(sum(x <= fbmax for x in f500M)) forbidden numbers <= $fbmax.")
end
</syntaxhighlight>{{out}}
<pre>
7 15 23 28 31 39 47 55 60 63
71 79 87 92 95 103 111 112 119 124
127 135 143 151 156 159 167 175 183 188
191 199 207 215 220 223 231 239 240 247
252 255 263 271 279 284 287 295 303 311
 
There are 82 forbidden numbers <= 500.
 
There are 831 forbidden numbers <= 5000.
 
There are 8330 forbidden numbers <= 50000.
 
There are 83331 forbidden numbers <= 500000.
 
There are 83333328 forbidden numbers <= 500000000.
</pre>
 
=={{header|Nim}}==
Uses the algorithm from the OEIS page.
<syntaxhighlight lang="Nim">import std/[math, strformat, strutils]
 
const Max = 500_000
 
func isForbidden(num: Positive): bool =
## Return "true" is "n" is a forbidden number.
var fours = num
var pow4 = 0
while fours > 1 and (fours and 3) == 0:
fours = fours shr 2
inc pow4
result = (num div 4^pow4 and 7) == 7
 
iterator forbiddenNumbers(): int =
var n = 1
while true:
if n.isForbidden:
yield n
inc n
 
var count = 0
var lim = 500
for n in forbiddenNumbers():
inc count
if count <= 50:
stdout.write &"{n:>3}"
stdout.write if count mod 10 == 0: '\n' else: ' '
if count == 50: echo()
elif n > lim:
echo &"Numbers of forbidden numbers up to {insertSep($lim)}: {insertSep($(count - 1))}"
lim *= 10
if lim > Max:
break
</syntaxhighlight>
 
{{out}}
<pre> 7 15 23 28 31 39 47 55 60 63
71 79 87 92 95 103 111 112 119 124
127 135 143 151 156 159 167 175 183 188
191 199 207 215 220 223 231 239 240 247
252 255 263 271 279 284 287 295 303 311
 
Numbers of forbidden numbers up to 500: 82
Numbers of forbidden numbers up to 5_000: 831
Numbers of forbidden numbers up to 50_000: 8_330
Numbers of forbidden numbers up to 500_000: 83_331
</pre>
 
Line 301 ⟶ 544:
uses
sysutils,strutils;
 
function isForbidden(n:NativeUint):boolean;inline;
// no need for power or div Only shr & AND when using Uint
// n > 7 => if n <= 7 -> only 4/0 would div 4 -> no forbidden number
Begin
while (n > 7) AND (n MOD 4 = 0) do
n := n DIV 4;
result := n MOD 8 = 7;
end;
 
function CntForbiddenTilLimit(lmt:NativeUint):NativeUint;
//nforNmb = 4^i * (8*j + 7) | i,j >= 0
//forNmb = Power4 * 8*j + Power4 * 7
//forNmb = delta* j + n
var
Power4,Deltadelta,n : NativeUint;
begin
result := 0;
power4 := 1;
repeat
delta := Power4*8;// j = 1
n := Power4*7;
if n > lmt then
Break;
//max j to reach limit
inc(result,(lmt-n) DIV delta+1);
Power4 *= 4;
until false;
end;
 
var
lmt,n,cnt: NativeUint;
BEGIN
writeln('First fifty forbidden numbers:');
n := 1;
lmt := 10;
repeat;
if isForbidden(n) then
Begin
write(n:4);
inc(lmt);
if LMT MOD 20 = 0 THEN
writeln;
end;
n +=1;
until lmt >= 50;
writeln;
writeln;
 
writeln('count of forbidden numbers below iterative');
n := 1;
cnt := 0;
lmt := 5;
repeat
repeat;
//if isForbidden(n) then cnt+=1 takes to long 100% -> 65% of time
inc(n);
inc(cnt,ORD(isForbidden(n)));
until CntForbiddenTilLimit(n) >= lmt;
write( n:4) += 1;
ifuntil LMT MOD 20n >= 0 THENlmt;
writeln(Numb2USA(IntToStr(lmt)):30,Numb2USA(IntToStr(Cnt)):25);
writeln;
lmt +*= 110;
until lmt > 50500*1000*1000;
writeln;
 
writeln;
writeln('count of forbidden numbers below ');
lmt := 5;
repeat
writeln(Numb2USA(IntToStr(lmt)):30,Numb2USA(IntToStr(CntForbiddenTilLimit(lmt))):25);
lmt *= 10;
Line 345 ⟶ 617:
{{out|@TIO.RUN}}
<pre>
 
First fifty forbidden numbers:
7 15 23 28 31 39 47 55 60 63 71 79 87 92 95 103 111 112 119 124
Line 350 ⟶ 623:
252 255 263 271 279 284 287 295 303 311
 
count of forbidden numbers below iterative
5 0
50 7
500 82
5,000 831
50,000 8,330
500,000 83,331
5,000,000 833,329
50,000,000 8,333,330
500,000,000 83,333,328
 
count of forbidden numbers below
5 0
50 7
Line 369 ⟶ 653:
50,000,000,000,000,000 8,333,333,333,333,325
500,000,000,000,000,000 83,333,333,333,333,323
Real time: 01.142392 s User time: 01.097343 s Sys. time: 0.040042 s CPU share: 9699.7352 %</pre>
 
=={{header|Perl}}==
<syntaxhighlight lang="perl" line>use strict;
use warnings;
use List::AllUtils 'firstidx';
use Lingua::EN::Numbers qw(num2en);
 
my $limit = 1 + int 5e6 / 8;
my @f = map { $_*8 - 1 } 1..$limit;
 
my($p0,$p1, @F) = (1,0, $f[0]);
do {
push @F, ($f[$p0] < $F[$p1]*4) ? $f[$p0++] : $F[$p1++]*4;
} until $p0 == $limit or $p1 == $limit;
 
printf "First %s forbidden numbers:\n", num2en 50;
print sprintf(('%4d')x50, @F[0..49]) =~ s/.{40}\K(?=.)/\n/gr;
print "\n\n";
 
for my $x (5e2, 5e3, 5e4, 5e5, 5e6) {
printf "%6d = forbidden number count up to %s\n", (firstidx { $_ > $x } @F), num2en($x);
}</syntaxhighlight>
{{out}}
<pre>
First fifty forbidden numbers:
7 15 23 28 31 39 47 55 60 63
71 79 87 92 95 103 111 112 119 124
127 135 143 151 156 159 167 175 183 188
191 199 207 215 220 223 231 239 240 247
252 255 263 271 279 284 287 295 303 311
 
82 = forbidden number count up to five hundred
831 = forbidden number count up to five thousand
8330 = forbidden number count up to fifty thousand
83331 = forbidden number count up to five hundred thousand
833329 = forbidden number count up to five million
</pre>
 
=={{header|Phix}}==
{{trans|Pascal}}
<!--<syntaxhighlight lang="phix">(phixonline)-->
<span style="color: #008080;">function</span> <span style="color: #000000;">forbidden</span><span style="color: #0000FF;">(</span><span style="color: #004080;">integer</span> <span style="color: #000000;">n</span><span style="color: #0000FF;">)</span>
<span style="color: #008080;">while</span> <span style="color: #000000;">n</span><span style="color: #0000FF;">></span><span style="color: #000000;">7</span> <span style="color: #008080;">and</span> <span style="color: #7060A8;">remainder</span><span style="color: #0000FF;">(</span><span style="color: #000000;">n</span><span style="color: #0000FF;">,</span><span style="color: #000000;">4</span><span style="color: #0000FF;">)=</span><span style="color: #000000;">0</span> <span style="color: #008080;">do</span>
<span style="color: #000000;">n</span> <span style="color: #0000FF;">/=</span> <span style="color: #000000;">4</span>
<span style="color: #008080;">end</span> <span style="color: #008080;">while</span>
<span style="color: #008080;">return</span> <span style="color: #7060A8;">remainder</span><span style="color: #0000FF;">(</span><span style="color: #000000;">n</span><span style="color: #0000FF;">,</span><span style="color: #000000;">8</span><span style="color: #0000FF;">)</span> <span style="color: #0000FF;">=</span> <span style="color: #000000;">7</span>
<span style="color: #008080;">end</span> <span style="color: #008080;">function</span>
<span style="color: #008080;">function</span> <span style="color: #000000;">forbidden_le_count</span><span style="color: #0000FF;">(</span><span style="color: #004080;">atom</span> <span style="color: #000000;">lmt</span><span style="color: #0000FF;">)</span>
<span style="color: #004080;">atom</span> <span style="color: #000000;">result</span> <span style="color: #0000FF;">=</span> <span style="color: #000000;">0</span><span style="color: #0000FF;">,</span> <span style="color: #000000;">Power4</span> <span style="color: #0000FF;">=</span> <span style="color: #000000;">1</span><span style="color: #0000FF;">,</span> <span style="color: #000000;">n</span> <span style="color: #0000FF;">=</span> <span style="color: #000000;">7</span>
<span style="color: #008080;">while</span> <span style="color: #000000;">n</span><span style="color: #0000FF;"><=</span><span style="color: #000000;">lmt</span> <span style="color: #008080;">do</span>
<span style="color: #004080;">atom</span> <span style="color: #000000;">delta</span> <span style="color: #0000FF;">:=</span> <span style="color: #000000;">Power4</span><span style="color: #0000FF;">*</span><span style="color: #000000;">8</span>
<span style="color: #000000;">result</span> <span style="color: #0000FF;">+=</span> <span style="color: #7060A8;">floor</span><span style="color: #0000FF;">((</span><span style="color: #000000;">lmt</span><span style="color: #0000FF;">-</span><span style="color: #000000;">n</span><span style="color: #0000FF;">)/</span><span style="color: #000000;">delta</span><span style="color: #0000FF;">)+</span><span style="color: #000000;">1</span><span style="color: #0000FF;">;</span>
<span style="color: #000000;">Power4</span> <span style="color: #0000FF;">*=</span> <span style="color: #000000;">4</span><span style="color: #0000FF;">;</span>
<span style="color: #000000;">n</span> <span style="color: #0000FF;">=</span> <span style="color: #000000;">Power4</span><span style="color: #0000FF;">*</span><span style="color: #000000;">7</span>
<span style="color: #008080;">end</span> <span style="color: #008080;">while</span>
<span style="color: #008080;">return</span> <span style="color: #000000;">result</span>
<span style="color: #008080;">end</span> <span style="color: #008080;">function</span>
<span style="color: #004080;">sequence</span> <span style="color: #000000;">f50</span> <span style="color: #0000FF;">=</span> <span style="color: #0000FF;">{}</span>
<span style="color: #004080;">integer</span> <span style="color: #000000;">i</span> <span style="color: #0000FF;">=</span> <span style="color: #000000;">0</span>
<span style="color: #008080;">while</span> <span style="color: #7060A8;">length</span><span style="color: #0000FF;">(</span><span style="color: #000000;">f50</span><span style="color: #0000FF;">)<</span><span style="color: #000000;">50</span> <span style="color: #008080;">do</span>
<span style="color: #008080;">if</span> <span style="color: #000000;">forbidden</span><span style="color: #0000FF;">(</span><span style="color: #000000;">i</span><span style="color: #0000FF;">)</span> <span style="color: #008080;">then</span> <span style="color: #000000;">f50</span> <span style="color: #0000FF;">&=</span> <span style="color: #000000;">i</span> <span style="color: #008080;">end</span> <span style="color: #008080;">if</span>
<span style="color: #000000;">i</span> <span style="color: #0000FF;">+=</span> <span style="color: #000000;">1</span>
<span style="color: #008080;">end</span> <span style="color: #008080;">while</span>
<span style="color: #7060A8;">printf</span><span style="color: #0000FF;">(</span><span style="color: #000000;">1</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"The first 50 forbidden numbers are:\n%s\n"</span><span style="color: #0000FF;">,</span>
<span style="color: #0000FF;">{</span><span style="color: #7060A8;">join_by</span><span style="color: #0000FF;">(</span><span style="color: #000000;">f50</span><span style="color: #0000FF;">,</span><span style="color: #000000;">1</span><span style="color: #0000FF;">,</span><span style="color: #000000;">10</span><span style="color: #0000FF;">,</span><span style="color: #008000;">" "</span><span style="color: #0000FF;">,</span><span style="color: #000000;">fmt</span><span style="color: #0000FF;">:=</span><span style="color: #008000;">"%3d"</span><span style="color: #0000FF;">)})</span>
<span style="color: #008080;">for</span> <span style="color: #000000;">t</span><span style="color: #0000FF;">=</span><span style="color: #000000;">2</span> <span style="color: #008080;">to</span> <span style="color: #7060A8;">iff</span><span style="color: #0000FF;">(</span><span style="color: #7060A8;">machine_bits</span><span style="color: #0000FF;">()=</span><span style="color: #000000;">32</span><span style="color: #0000FF;">?</span><span style="color: #000000;">16</span><span style="color: #0000FF;">:</span><span style="color: #000000;">17</span><span style="color: #0000FF;">)</span> <span style="color: #008080;">do</span>
<span style="color: #004080;">atom</span> <span style="color: #000000;">lmt</span> <span style="color: #0000FF;">=</span> <span style="color: #000000;">5</span><span style="color: #0000FF;">*</span><span style="color: #7060A8;">power</span><span style="color: #0000FF;">(</span><span style="color: #000000;">10</span><span style="color: #0000FF;">,</span><span style="color: #000000;">t</span><span style="color: #0000FF;">),</span> <span style="color: #000000;">count</span> <span style="color: #0000FF;">=</span> <span style="color: #000000;">forbidden_le_count</span><span style="color: #0000FF;">(</span><span style="color: #000000;">lmt</span><span style="color: #0000FF;">)</span>
<span style="color: #7060A8;">printf</span><span style="color: #0000FF;">(</span><span style="color: #000000;">1</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"Forbidden numbers up to %,d: %,d\n"</span><span style="color: #0000FF;">,{</span><span style="color: #000000;">lmt</span><span style="color: #0000FF;">,</span><span style="color: #000000;">count</span><span style="color: #0000FF;">})</span>
<span style="color: #008080;">end</span> <span style="color: #008080;">for</span>
<!--</syntaxhighlight>-->
{{out}}
<pre>
The first 50 forbidden numbers are:
7 15 23 28 31 39 47 55 60 63
71 79 87 92 95 103 111 112 119 124
127 135 143 151 156 159 167 175 183 188
191 199 207 215 220 223 231 239 240 247
252 255 263 271 279 284 287 295 303 311
 
Forbidden numbers up to 500: 82
Forbidden numbers up to 5,000: 831
Forbidden numbers up to 50,000: 8,330
Forbidden numbers up to 500,000: 83,331
Forbidden numbers up to 5,000,000: 833,329
Forbidden numbers up to 50,000,000: 8,333,330
Forbidden numbers up to 500,000,000: 83,333,328
Forbidden numbers up to 5,000,000,000: 833,333,330
Forbidden numbers up to 50,000,000,000: 8,333,333,327
Forbidden numbers up to 500,000,000,000: 83,333,333,328
Forbidden numbers up to 5,000,000,000,000: 833,333,333,327
Forbidden numbers up to 50,000,000,000,000: 8,333,333,333,327
Forbidden numbers up to 500,000,000,000,000: 83,333,333,333,326
Forbidden numbers up to 5,000,000,000,000,000: 833,333,333,333,327
Forbidden numbers up to 50,000,000,000,000,000: 8,333,333,333,333,325
Forbidden numbers up to 500,000,000,000,000,000: 83,333,333,333,333,323
</pre>
 
Line 443 ⟶ 824:
 
Forbidden number count up to five million: 833,329</pre>
 
=={{header|RPL}}==
{{trans|XPLo}}
≪ R→B
'''WHILE''' #0d OVER ≠ LAST #3d AND == AND '''REPEAT''' SR SR '''END'''
#7d AND B→R 7 ==
≫ ''''FORB?'''' STO
≪ 0 1 3 PICK '''FOR''' j '''IF''' j '''FORB? THEN''' 1 + '''END NEXT'''
≫ ''''NFORB'''' STO
 
≪ { } 0 '''WHILE''' OVER SIZE 50 < '''REPEAT''' 1 + '''IF''' DUP '''FORB? THEN''' SWAP OVER + SWAP '''END END''' DROP ≫
500 '''NFORB'''
5000 '''NFORB'''
50000 '''NFORB'''
{{out}}
<pre>
4: { 7 15 23 28 31 39 47 55 60 63 71 79 87 92 95 103 111 112 119 124 127 135 143 151 156 159 167 175 183 188 191 199 207 215 220 223 231 239 240 247 252 255 263 271 279 284 287 295 303 311 }
3: 82
2: 831
1: 8330
</pre>
 
=={{header|Sidef}}==
<syntaxhighlight lang="ruby">say ("First 50 terms: ", 50.by { .squares_r(3) == 0 })
 
for n in (500, 5_000, 50_000, 500_000) {
var v = (1..n -> count {|n|
idiv(n, ipow(4, n.valuation(4))).is_congruent(7, 8)
})
say "There are #{v} forbidden numbers up to #{n.commify}."
}</syntaxhighlight>
{{out}}
<pre>
First 50 terms: [7, 15, 23, 28, 31, 39, 47, 55, 60, 63, 71, 79, 87, 92, 95, 103, 111, 112, 119, 124, 127, 135, 143, 151, 156, 159, 167, 175, 183, 188, 191, 199, 207, 215, 220, 223, 231, 239, 240, 247, 252, 255, 263, 271, 279, 284, 287, 295, 303, 311]
There are 82 forbidden numbers up to 500.
There are 831 forbidden numbers up to 5,000.
There are 8330 forbidden numbers up to 50,000.
There are 83331 forbidden numbers up to 500,000.
</pre>
 
=={{header|Wren}}==
Line 448 ⟶ 869:
{{libheader|Wren-fmt}}
This uses a sieve to filter out those numbers which are the sums of one, two or three squares. Works but very slow (c. 52 seconds).
<syntaxhighlight lang="ecmascriptwren">import "./fmt" for Fmt
 
var forbidden = Fn.new { |limit, countOnly|
Line 503 ⟶ 924:
===Version 2===
This is a translation of the formula-based Python code in the OEIS link which at around 1.1 seconds is almost 50 times faster than Version 1 and is also about 3 times faster than the PARI code in that link.
<syntaxhighlight lang="ecmascriptwren">import "./fmt" for Fmt
 
var isForbidden = Fn.new { |n|
Line 527 ⟶ 948:
<pre>
Same as Version 1
</pre>
 
=={{header|XPL0}}==
Runtime is around 7.5 seconds on a Raspberry Pi4.
<syntaxhighlight lang "XPL0">include xpllib; \for RlOutC
 
func Forbidden(N); \Return 'true' if N is a forbidden number
int N;
[while (N&3) = 0 and N do N:= N>>2;
return (N&7) = 7;
];
 
int N, Count, Limit;
[Text(0, "The first 50 forbidden numbers are:^m^j");
Format(4, 0);
N:= 0; Count:= 0;
while Count < 50 do
[if Forbidden(N) then
[RlOut(0, (float(N)));
Count:= Count+1;
if rem(Count/10) = 0 then CrLf(0);
];
N:= N+1;
];
CrLf(0);
Format(9, 0);
N:= 1; Count:= 0; Limit:= 500;
loop [if Forbidden(N) then Count:= Count+1;
if N = Limit then
[Text(0, "Forbidden number count <= ");
RlOutC(0, float(Limit));
RlOutC(0, float(Count));
CrLf(0);
if Limit = 500_000_000 then quit;
Limit:= Limit * 10;
];
N:= N+1;
];
]</syntaxhighlight>
{{out}}
<pre>
The first 50 forbidden numbers are:
7 15 23 28 31 39 47 55 60 63
71 79 87 92 95 103 111 112 119 124
127 135 143 151 156 159 167 175 183 188
191 199 207 215 220 223 231 239 240 247
252 255 263 271 279 284 287 295 303 311
 
Forbidden number count <= 500 82
Forbidden number count <= 5,000 831
Forbidden number count <= 50,000 8,330
Forbidden number count <= 500,000 83,331
Forbidden number count <= 5,000,000 833,329
Forbidden number count <= 50,000,000 8,333,330
Forbidden number count <= 500,000,000 83,333,328
</pre>
2,747

edits