Esempio n. 1
0
def num_divisors(n):
    f = factor(n)
    count = 0
    val = 0
    prod = 1
    for p in f:
        if p != val:
            prod *= count + 1
            count = 0
        val = p
        count += 1
    prod *= count + 1
    return prod
Esempio n. 2
0
def totient(n):
  f = list(factor(n))
  prod = 1
  for p in f:
    prod *= (1 - float(1) / p)
  return int(round(prod * n))
Esempio n. 3
0
def c_n(n):
  return sum(factor(n).keys())
Esempio n. 4
0
from helpers import factor, cached_prime

limit = 1000000
cached_prime(limit)

c0 = len(factor(6))
c1 = len(factor(7))
c2 = len(factor(8))
c3 = len(factor(9))
for i in range(10, limit):
  c0 = c1
  c1 = c2
  c2 = c3
  c3 = len(factor(i))
  if c0 == 4 and c1 ==4 and c3 == 4 and c2 == 4:
    print i-3
Esempio n. 5
0
"""
Problem 3: Largest prime factor

The prime factors of 13195 are 5, 7, 13 and 29.

What is the largest prime factor of the number 600851475143?
"""

from helpers import factor

print(factor(600851475143))