diff -r ae4bcaff1dde -r 8f4c369a41f1 using-sage/questions.rst --- a/using-sage/questions.rst Mon Nov 08 11:00:08 2010 +0530 +++ b/using-sage/questions.rst Mon Nov 08 11:39:07 2010 +0530 @@ -64,21 +64,36 @@ Programming ----------- -1. What is the out put of the following code:: +1. Obtain the sum of primes between 1 million and 2 million. + + Answer:: - c1 = Combinations([1, 2, 3, 4]) - c2 = Combinations([1, 2, 4, 3]) + prime_sum = 0 + for i in range(1000001, 2000000, 2): + if is_prime(i): + prime_sum += i + + prime_sum - l1 = c1.list() - l2 = c2.list() + OR + :: + + sum(prime_range(1000000, 2000000)) - for i in l2: - l1.remove(i) +2. ``graphs.WorldMap()`` gives the world map in the form of a + graph. :: - print l2 + G = graphs.WorldMap() + G.vertices() - Answer: [] + + Suppose, I wish to go from India to France by Road, find out the + least number of Visas that I'll have to obtain. + + Answer:: -.. #[[Anoop: add one more question to this part, probably a small - problem asking them to solve it, project euler has problems on - combinations and all]] + G.distance("India", "France") + + + +