Truncatable primes: Difference between revisions

Content deleted Content added
Line 354: Line 354:
else
else
left = Math.floor n / 10
left = Math.floor n / 10
right = n % 10
while left > 0
while left > 0
left = max_right_truncatable_number left, f
left = max_right_truncatable_number left, f
right = 9
while right > 0
while right > 0
candidate = left * 10 + right
candidate = left * 10 + right
return candidate if f(candidate)
return candidate if candidate <= n and f(candidate)
right -= 1
right -= 1
left -= 1
left -= 1
right = 9
throw Error "none found"
throw Error "none found"