Inventory sequence: Difference between revisions

Added XPL0 example.
(Added FreeBASIC)
(Added XPL0 example.)
Line 449:
[[File:Inventory-wren.png|500px|thumb|left]]
<br clear=all>
 
=={{header|XPL0}}==
<syntaxhighlight lang "XPL0">include xpllib; \for Print
 
def Size = 201_790;
int Seq(Size), SeqEnd, Num, Count, N, Thresh;
[SeqEnd:= 0;
loop [Num:= 0;
repeat Count:= 0;
for N:= 0 to SeqEnd-1 do
if Num = Seq(N) then Count:= Count+1;
Seq(SeqEnd):= Count;
SeqEnd:= SeqEnd+1;
if SeqEnd >= Size then quit;
Num:= Num+1;
until Count = 0;
];
Thresh:= 1000;
for N:= 0 to SeqEnd-1 do
if N < 100 then
[Print("%3.0f", float(Seq(N)));
if rem(N/20) = 19 then CrLf(0);
]
else if Seq(N) >= Thresh then
[Print("First element >= %5.0f: %5.0f in position %6.0f\n",
float(Thresh), float(Seq(N)), float(N));
if Thresh >= 10000 then return;
Thresh:= Thresh + 1000;
];
]</syntaxhighlight>
{{out}}
<pre>
0 1 1 0 2 2 2 0 3 2 4 1 1 0 4 4 4 1 4 0
5 5 4 1 6 2 1 0 6 7 5 1 6 3 3 1 0 7 9 5
3 6 4 4 2 0 8 9 6 4 9 4 5 2 1 3 0 9 10 7
5 10 6 6 3 1 4 2 0 10 11 8 6 11 6 9 3 2 5 3
2 0 11 11 10 8 11 7 9 4 3 6 4 5 0 12 11 10 9 13
First element >= 1000: 1001 in position 24255
First element >= 2000: 2009 in position 43301
First element >= 3000: 3001 in position 61708
First element >= 4000: 4003 in position 81456
First element >= 5000: 5021 in position 98704
First element >= 6000: 6009 in position 121342
First element >= 7000: 7035 in position 151756
First element >= 8000: 8036 in position 168804
First element >= 9000: 9014 in position 184428
First element >= 10000: 10007 in position 201788
</pre>
297

edits