예제 #1
0
def main():
    print('''    The prime factors of 13195 are 5, 7, 13 and 29.
    What is the largest prime factor of the number 600851475143 ? (6,857)''')
    N = 600851475143
    n = 10
    r = 3
    t = [1]
    o = sys.modules[__name__]
    u = usage
    util.runTests({'N': N}, {'n': n, 'r': r, 't': t, 'o': o, 'u': u})
def main():
    print('''    A palindromic number reads the same both ways. The largest palindrome made from the product of two 2-digit numbers is 9009 = 91 * 99.
    Find the largest palindrome made from the product of two 3-digit numbers. (906,609)''')
    N = 3
    n = 10
    r = 3
    t = [1]
    o = sys.modules[__name__]
    u = usage
    util.runTests({'N': N}, {'n': n, 'r': r, 't': t, 'o': o, 'u': u})
예제 #3
0
def main():
    print('''    By listing the first six prime numbers: 2, 3, 5, 7, 11, and 13, we can see that the 6th prime is 13.
    What is the 10 001st prime number? (104,743)''')
    N = 10001
    n = 20
    r = 3
    t = [1]
    o = sys.modules[__name__]
    u = usage
    util.runTests({'N': N}, {'n': n, 'r': r, 't': t, 'o': o, 'u': u})
예제 #4
0
def main():
    print('''    The sum of the primes below 10 is 2 + 3 + 5 + 7 = 17
    Find the sum of all primes below two million. (142,913,828,922)''')
    N = 100000
    n = 10
    r = 3
    t = [1, 2]
    o = sys.modules[__name__]
    u = usage
    util.runTests({'N': N}, {'n': n, 'r': r, 't': t, 'o': o, 'u': u})
예제 #5
0
def main():
    print(
        '''    2520 is the smallest number that can be divided by each of the numbers from 1 to 10 without any remainder.
    What is the smallest positive number that is evenly divisible by all of the numbers from 1 to 20? (232,792,560)'''
    )
    N = 20
    n = 20
    r = 3
    t = [1]
    o = sys.modules[__name__]
    u = usage
    util.runTests({'N': N}, {'n': n, 'r': r, 't': t, 'o': o, 'u': u})
예제 #6
0
def main():
    print(
        '''    If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23.
    Find the sum of all the multiples of 3 or 5 below 1000. (233,168)''')
    N = 100
    P = [3, 5]
    n = 10
    r = 3
    t = [1]
    o = sys.modules[__name__]
    u = usage
    util.runTests({'N': N, 'P': P}, {'n': n, 'r': r, 't': t, 'o': o, 'u': u})
예제 #7
0
def main():
    print(
        '''    Each new term in the Fibonacci sequence is generated by adding the previous two terms. By starting with 1 and 2, the first 10 terms will be:
    1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ...
    By considering the terms in the Fibonacci sequence whose values do not exceed four million, find the sum of the even-valued terms. (4,613,732)'''
    )
    N = 4000000
    n = 10
    r = 3
    t = [1]
    o = sys.modules[__name__]
    u = usage
    util.runTests({'N': N}, {'n': n, 'r': r, 't': t, 'o': o, 'u': u})
def main():
    print(
        '''    A Pythagorean triplet is a set of three natural numbers, a < b < c, for which a**2 + b**2 = c**2
    For example 3**2 + 4**2 = 9 + 16 = 25 = 5**2
    There exists exactly one Pythagorean triplet for which a + b + c = 1000.  Find the product abc. (31,875,000)'''
    )
    N = 1000
    M = 4
    n = 10
    r = 1
    t = [1]
    o = sys.modules[__name__]
    u = usage
    util.runTests({'N': N}, {'n': n, 'r': r, 't': t, 'o': o, 'u': u})
def main():
    print(
        '''    The four adjacent digits in the 1000-digit number that have the greatest product are 9 * 9 * 8 * 9 = 5832
    Find the thirteen adjacent digits in the 1000-digit number that have the greatest product. What is the value of this product?
    23,514,624,000 = 5 * 5 * 7 * 6 * 6 * 8 * 9 * 6 * 6 * 4 * 8 * 9 * 5''')
    N = 1000
    M = 4
    n = 10
    r = 1
    t = [1]
    o = sys.modules[__name__]
    u = usage
    print('{}'.format(d))
    util.runTests({'N': N, 'M': M}, {'n': n, 'r': r, 't': t, 'o': o, 'u': u})
예제 #10
0
def main():
    print(
        '''    The sum of the squares of the first ten natural numbers is 1**2 + 2**2 + ... + 10**2 = 385
    The square of the sum of the first ten natural numbers is (1 + 2 + ... + 10)**2 = 3025
    Hence the difference between the sum of the squares of the first ten natural numbers and the square of the sum is 3025 - 385 = 2640
    Find the difference between the sum of the squares of the first one hundred natural numbers and the square of the sum (25,164,150)'''
    )
    N = 100
    n = 20
    r = 3
    t = [1]
    o = sys.modules[__name__]
    u = usage
    util.runTests({'N': N}, {'n': n, 'r': r, 't': t, 'o': o, 'u': u})