b = c + a c = b + a return s def e0002_006(): a, b, c = 2, 3, 5 while c < MAX: a = b + c b = c + a c = b + a return (c - 1) // 2 def e0002_007(): a, b = 0, 2 while b < MAX: a, b = b, a + 4*b return (b+a-2)//4 from math import log def e0002_008(): sq = 5 ** .5 n = log(MAX * sq)//log(2 + sq) x = (2 + sq) y = (2 - sq) return int(((x-x**(n+1)) / (1-x) - (y-y**(n+1)) / (1-y))/sq) # Better for HUGE MAX if __name__ == '__main__': from __init__ import start start(e0002_000())
n = (n - 1)/x return x * n/2. * (n + 1) return sumx(1000,5) + sumx(1000,3) - sumx(1000,15) def e0001_010(): def sumx(n,x): n = (n - 1)//x return x * n/2. * (n + 1) return sumx(1000,5) + sumx(1000,3) - sumx(1000,15) def e0001_011(): def sumx(n,x): n = (n - 1)//x return x * n * (n + 1) / 2 return sumx(1000,5) + sumx(1000,3) - sumx(1000,15) def e0001_012(): def sumx(n,x): n = (n - 1)//x return x * n * (n + 1) // 2 return sumx(1000,5) + sumx(1000,3) - sumx(1000,15) if __name__ == '__main__': from __init__ import start start(e0001_000())