diff --git a/README.markdown b/README.markdown index 8a68700..c390460 100644 --- a/README.markdown +++ b/README.markdown @@ -38,9 +38,14 @@ Should be used in order to help future reuse of code :) 23 - Find the sum of all the positive integers which cannot be written as the sum of two abundant numbers. 24 - What is the millionth lexicographic permutation of the digits 0, 1, 2, 3, 4, 5, 6, 7, 8 and 9? 25 - What is the first term in the Fibonacci sequence to contain 1000 digits? +27 - Find a quadratic formula that produces the maximum number of primes for consecutive values of n. 48 - Find the last ten digits of 1^1 + 2^2 + ... + 1000^1000. 67 - Using an efficient algorithm find the maximal sum in the triangle? +**In progress: ** + +26 - Find the value of d < 1000 for which 1/d contains the longest recurring cycle. +36 - Find the sum of all numbers less than one million, which are palindromic in base 10 and base 2. **WARNING : Spoil inside for those who want to solve problems by themselves :)** diff --git a/e_27.py b/e_27.py index 51dc03c..b136d27 100644 --- a/e_27.py +++ b/e_27.py @@ -45,37 +45,32 @@ def prime_series(a_range, b_range): """ Returns the product of a and b for the quad_fun that produces the max number of primes; a_range, b_range being the ranges for a and b - """ - prints = len(a_range) * len(b_range) - a_print = 0 - b_print = 0 - + """ max = 0 max_prod = 0 + + a_curr = 0 for a in a_range: - a_print += 1 + a_curr += 1 + print "%d/%d" %(a_curr, len(a_range)) for b in b_range: - b_print += 1 - - # status message - curr_print = (a_print - 1) * len(b_range) + b_print % (len(b_range) ) - print "%d/%d" % (curr_print, prints) n = 0 value = quad_fun(a, b, n) - while is_prime(value): + while is_prime(abs(value)): n += 1 value = quad_fun(a, b, n) # checking if current serie if the best we got : if n > max: max = n - max_prod = abs(a) * abs(b) + max_prod = a * b return max_prod if __name__ == '__main__' : - a_range = range(-1000, 1001) - b_range = range(-1000, 1001) + a_range = range(-999, 1000) + b_range = range(-999, 1000) + print "Answer is : %d" % (prime_series(a_range, b_range)) raw_input() \ No newline at end of file diff --git a/e_36.py b/e_36.py new file mode 100644 index 0000000..f1e97b1 --- /dev/null +++ b/e_36.py @@ -0,0 +1,18 @@ +#!/usr/bin/env python +""" + ##--- + # Julien Lengrand-Lambert + #Created on : Thu Jan 19 10:12:06 CET 2012 + # + # DESCRIPTION : Solves problem 36 of Project Euler + The decimal number, 585 = 10010010012 (binary), is palindromic in both bases. + Find the sum of all numbers, less than one million, which are palindromic in base 10 and base 2. + + (Please note that the palindromic number, in either base, may not include leading zeros.) + ##--- + """ + +if __name__ == '__main__' : + + print "Answer is : %d" % (1) + raw_input() \ No newline at end of file