Add is_palindrome function

This commit is contained in:
David Doblas Jiménez 2021-10-02 18:49:03 +02:00
parent 9555105815
commit 5add43f07c

View File

@ -41,4 +41,8 @@ def list_primality(n):
# Returns all the prime numbers less than or equal to n, in ascending order # Returns all the prime numbers less than or equal to n, in ascending order
# For example: list_primes(97) = [2, 3, 5, 7, 11, ..., 83, 89, 97]. # For example: list_primes(97) = [2, 3, 5, 7, 11, ..., 83, 89, 97].
def list_primes(n): def list_primes(n):
return [i for (i, is_prime) in enumerate(list_primality(n)) if is_prime] return [i for (i, is_prime) in enumerate(list_primality(n)) if is_prime]
def is_palidrome(num):
return str(num) == str(num)[::-1]