aUCBLogo Demos and Tests / palindromic_numbers
to palindromic_numbers
precision=100
maxiter=100
BigFloatSetPrecision precision
pp BigFloat 100000 200000
end
to pp :j :k
make "n 0
runp :j :k
print (list "#... :n "...#)
end
to pcheck :x
if :i==maxiter [print (list "TOO "MUCH :x) print
(list "......... "# maxiter "+) make "n :n+1 stop]
make "y reverse :x
make "z :x+:y
make "i :i+1
if :z==(reverse :z) [print (list "....... :z) print
(list "......... "# :i) stop]
pcheck :z
end
to pcheck2 :x
if :i==maxiter
[ print :j
dispatchMessages
make "n :n+1 stop
]
make "y reverse :x
make "z :x+:y
make "i :i+1
if :z==(reverse :z) [stop]
pcheck2 :z
end
to pal :x
make "i 0
pcheck2 :x
end
to runp :j :k
if :j > :k [stop]
;show :j
pal :j
runp :j+1 :k
end