def trunc(n): c = n while c>10: c = c % 10**(int(log10(c))) n = n//10 if not isPrime(c) or not isPrime(n): return False return True
def phi(n): # return len([i for i in range(1,n) if mcd(i,n)==1]) if isPrime(n): return n-1 else: prod = float(n) factores = factorization(n) for i in factores: prod = prod * (1 - (1/float(i))) return int(prod)
""" The sum of the primes below 10 is 2 + 3 + 5 + 7 = 17. Find the sum of all the primes below two million. """ import reto7 if __name__ == "__main__": print sum([long(i) for i in range(2 * (10 ** 6)) if reto7.isPrime(i) and i > 1])
#!/usr/bin/env python """ The prime factors of 13195 are 5, 7, 13 and 29. What is the largest prime factor of the number 600851475143 ? """ import math import reto7 def esPrimo(n): for i in range(n): if i!=0 and i!=1 and i!=2: if n%i==0: return False return True if __name__ == "__main__": num = 600851475143L #lista = [long(i) for i in reversed(long(num)) if i!=0 and num%i==0 and esPrimo(i)] for i in reversed(range(long(math.sqrt(num)))): if num % i == 0 and reto7.isPrime(i): lista = i break print lista