RosettaCodeData/Task/Babbage-problem/XPL0/babbage-problem.xpl0

23 lines
721 B
Plaintext

int N, C, R;
[C:= 0;
for N:= sqrt(269696) to -1>>1 do \to infinity (2^31-1)
if rem(N/10)=4 or rem(N/10)=6 then \must end 6: 4^2=16; 6^2=36
[R:= rem(N/100);
if R=14 or R=36 or R=64 or R=86 then \14^2=196, etc.
[R:= rem(N/1000);
if R=236 or R=264 or R=736 or R=764 then \236^2=55696, etc.
[C:= C+1; \count remaining tests
if rem(N*N/1_000_000) = 269_696 then
[IntOut(0, N);
Text(0, "^^2 = ");
IntOut(0, N*N);
CrLf(0);
IntOut(0, C);
CrLf(0);
exit;
];
];
];
];
]