Data update

This commit is contained in:
Ingy döt Net 2023-12-16 21:33:55 -08:00
parent 35bcdeebf8
commit 74c69a0df6
2427 changed files with 31826 additions and 3468 deletions

View file

@ -1,8 +1,13 @@
"""
babbage(x::Integer)
Returns the smallest positive integer whose square ends in `x`
"""
function babbage(x::Integer)
i = big(0)
d = floor(log10(x)) + 1
while i ^ 2 % 10 ^ d != x
i += 1
i = big(0) # start with 0 and increase by 1 until target reaached
d = 10^ndigits(x) # smallest power of 10 greater than x
while (i * i) % d != x
i += 1 # try next squre of numbers 0, 1, 2, ...
end
return i
end