예제 #1
0
'''
Created on Mar 31, 2014

@author: kan
'''

import src.solution.Mytools as Mt
N = 100000
primes = Mt.primes2(N)

def compute_r(n):
    if n==0 or n==1:
        return n    
    rad = 1
    for p in primes:
        if n%p == 0:
            rad *= p
            n//=p
            while n % p == 0:
                n //= p
        if n==1:
            return rad
        
class radical:
    def __init__(self, n):
        self.n = n
        self.r = compute_r(n)
    def __lt__(self, rad2):
        return self.r < rad2.r or self.r==rad2.r and self.n < rad2.n
        
class ordered_radicals:
예제 #2
0
"""
Created on Mar 29, 2013

@author: kan
"""
import src.solution.Mytools as Mt

primes = Mt.primes2(1000003)


def S(p1, p2):
    l = len(str(p2))
    dig = 10 ** l
    p = p2
    while p % dig != p1:
        p += p2
    return p


sum = 0
for i in range(2, len(primes) - 1):
    sum += S(primes[i], primes[i + 1])
print(sum)