Kaprekar numbers
Posted: Thu Sep 07, 2017 6:48 pm
This program calculates Kaprekar numbers:
Output:
Code: Select all
kap,n = getkap(10000)
> i, 1..n
#.output(kap[i])
<
getkap(x)=
> k, 1..x
n = #.lower(#.log10(k^2))+1
> i, 1..n
r = k^2%10^i
<< r>k
>> r=0
l = #.lower(k^2/10^i)
? r+l=k, kap[#.size(kap,1)+1] = k
<
<
<= kap,#.size(kap,1)
.
Code: Select all
1
9
45
55
99
297
703
999
2223
2728
4879
4950
5050
5292
7272
7777
9999