Permuted multiples: Difference between revisions
Content added Content deleted
(Added C++ solution) |
(Added XPL0 example.) |
||
Line 829: | Line 829: | ||
5 x n = 714285 |
5 x n = 714285 |
||
6 x n = 857142 |
6 x n = 857142 |
||
</pre> |
|||
=={{header|XPL0}}== |
|||
<lang XPL0>func Digits(N); \Return counts of digits packed in 30 bits |
|||
int N, Sums; |
|||
[Sums:= 0; |
|||
repeat N:= N/10; |
|||
Sums:= Sums + 1<<(rem(0)*3); |
|||
until N = 0; |
|||
return Sums; |
|||
]; |
|||
int N, Sums; |
|||
[N:= 1; |
|||
loop [Sums:= Digits(N*2); |
|||
if Digits(N*3) = Sums then |
|||
if Digits(N*4) = Sums then |
|||
if Digits(N*5) = Sums then |
|||
if Digits(N*6) = Sums then |
|||
quit; |
|||
N:= N+1; |
|||
]; |
|||
IntOut(0, N); |
|||
]</lang> |
|||
{{out}} |
|||
<pre> |
|||
142857 |
|||
</pre> |
</pre> |