Jump to content

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

→‎{{header|Euler}}: Sybntax highlight with Mediawiki markup
m (→‎{{header|RPL}}: optimized code)
(→‎{{header|Euler}}: Sybntax highlight with Mediawiki markup)
Line 173:
=={{header|Euler}}==
As with the Arturo, F# etc. samples, generates the sequence but doesn't sort it into order.
'''begin''' '''new''' dPos; '''new''' non1digits; '''label''' digitLoop;
<syntaxhighlight lang="euler">
begin new dPos; new non1digits &lt;- ( 0, 2, 3, 4, 5, 6, 7, 8, label9 digitLoop);
non1digits <dPos &lt;- ( 0, 2, 3, 4, 5, 6, 7, 8, 9 );
digitLoop: '''if''' [ dPos <&lt;- dPos + 1 ] <&lt;= '''length''' non1digits '''then''' '''begin'''
dPos <- 0 '''new''' d;
digitLoop: if [ dPos <- dPos + 1 ] <= length non1digits then begin
new d &lt;- non1digits[ dPos ];
'''out''' [ d <-* 100 ] + 11; '''out''' non1digits[ dPosd * 10 ] + 101; '''out''' 110 + d;
out ['''goto''' d * 100 ] + 11; out [ d * 10 ] + 101; out 110 + d;digitLoop
'''end''' '''else''' goto digitLoop0
'''end''' $
end else 0
end $
</syntaxhighlight>
{{out}}
<pre>
3,043

edits

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