コード例 #1
0
 1: 1
 3: 1,3
 6: 1,2,3,6
10: 1,2,5,10
15: 1,3,5,15
21: 1,3,7,21
28: 1,2,4,7,14,28
We can see that 28 is the first triangle number to have over five divisors.

What is the value of the first triangle number to have over five hundred divisors?
"""
from collections import Counter
from functools import reduce
from helpers.primes import primes_below

prime_list = primes_below(65501)


def nth_triangle(n):
    return (n + 1) * n // 2


def count_divs_old(num):
    count = 0
    for i in range(1, num + 1):
        if num % i == 0:
            count += 1
    return count


def count_divs(num):
コード例 #2
0
"""
https://projecteuler.net/problem=10
The sum of the primes below 10 is 2 + 3 + 5 + 7 = 17.
Find the sum of all the primes below two million.
"""
from helpers.primes import primes_below

# answer
print(sum(primes_below(2000000)))