Jump to content

Positive decimal integers with the digit 1 occurring exactly twice: Difference between revisions

→‎{{header|Euler}}: Replace with generative, non-sorted version inspired by the Arturo, F# etc, samples
(→‎{{header|Euler}}: Replace with generative, non-sorted version inspired by the Arturo, F# etc, samples)
Line 172:
 
=={{header|Euler}}==
As with the Arturo, F# etc. samples, generates the sequence but doesn't sort it into order.
<syntaxhighlight lang="euler">
begin new dPos; new inon1digits; label iLoopdigitLoop;
i non1digits <- ( 0, 2, 3, 4, 5, 6, 7, 8, 9 );
iLoop: if [ i <- i + 1 ] < 1000 thendPos <- begin0;
digitLoop: if [ dPos <- dPos + 1 ] <= length non1digits then begin
new v; new oneCount; label vloop;
oneCount <- 0 new d;
v d <- inon1digits[ dPos ];
out [ d * 100 ] + 11; out [ d * 10 ] + 101; out 110 + d;
vLoop: if v > 0 then begin
if [goto v mod 10 ] = 1 then oneCount <- oneCount + 1digitLoop
end else 0;
v <- v % 10;
goto vLoop
end else 0;
if oneCount = 2 then out i else 0;
goto iLoop
end else 0
end $
</syntaxhighlight>
Line 195 ⟶ 190:
NUMBER 101
NUMBER 110
NUMBER 112
NUMBER 113
NUMBER 114
NUMBER 115
NUMBER 116
NUMBER 117
NUMBER 118
NUMBER 119
NUMBER 121
NUMBER 131
NUMBER 141
NUMBER 151
NUMBER 161
NUMBER 171
NUMBER 181
NUMBER 191
NUMBER 211
NUMBER v <- v % 10; 121
NUMBER goto vLoop 112
NUMBER 311
NUMBER 112131
NUMBER 113
NUMBER 411
NUMBER 121141
NUMBER 114
NUMBER 511
NUMBER 131151
NUMBER 115
NUMBER 611
NUMBER 141161
NUMBER 116
NUMBER 711
NUMBER 151171
NUMBER 117
NUMBER 811
NUMBER 161181
NUMBER 118
NUMBER 911
NUMBER 171191
NUMBER 119
</pre>
 
3,043

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.