Question: Solution in Python taking command line arguments. 1. Ramanujans taxi Problem. S. Ramanujan was an Indian mathematician who became famous for his intuition for numbers.

Solution in Python taking command line arguments.

1. Ramanujans taxi Problem. S. Ramanujan was an Indian mathematician who became famous for his intuition for numbers. When the English mathematician G. H. Hardy came to visit him in the hospital one day, Hardy remarked that the number of his taxi was 1729, a rather dull number. To which Ramanujan replied, "No, Hardy! No, Hardy! It is a very interesting number. It is the smallest number expressible as the sum of two cubes in two different ways." Verify this claim by composing a program that takes a command line argument n and writes all integers less than or equal to n that can be expressed as the sum of two cubes in two different ways. In other words, find distinct positive integers a, b, c, and d such that a3 + b3 = c3 + d3. Hint: review chapter 4-7 for nested loops. Note: You MUST provide solutions for both for loop and while loop. And your output MUST have the following format:

$ python ramanujanfor.py 2000 1729 = 1^3 + 12^3 = 9^3 + 10^3

$ python ramanujanfor.py 10000 1729 = 1^3 + 12^3 = 9^3 + 10^3 4104 = 2^3 + 16^3 = 9^3 + 15^3

2. Euler's sum-of-powers conjecture. In 1769 Leonhard Euler formulated a generalized version of Fermat's Last Theorem, conjecturing that at least n n-th powers are needed to obtain a sum that is itself a nth power, for n > 2. Compose a program to disprove Euler's conjecture (which stood until 1967), using a quintuply nested loop to find four positive integers whose 5th power sums to the 5th power of another positive integer. That is, find five distinct positive integers a, b, c, d, and e such that a5 + b5 + c5 + d5 = e5. Hint: review chapter 4-7 for nested loops. Note: You MUST provide solutions for both for loop and while loop. And your output MUST have the following format:

$ python eulerSum.py 200 27^5 + 84^5 + 110^5 + 133^5 = 144^5

10. Checksums. The International Standard Book Number (ISBN) is a 10 digit code that uniquely specifies a book. The rightmost digit is a checksum digit which can be uniquely determined from the other 9 digits from the condition that d1 + 2d2 + 3d3 + ... + 10d10 must be a multiple of 11 (here di denotes the ith digit from the right). The checksum digit d1 can be any value from 0 to 10: the ISBN convention is to use the value 'X' to denote 10. Example: the checksum digit corresponding to 020131452 is 5 since is the only value of d1 between 0 and 10 for which d1 + 2*2 + 3*5 + 4*4 + 5*1 + 6*3 + 7*1 + 8*0 + 9*2 + 10*0 is a multiple of 11. Compose a program that takes a 9-digit integer as a command-line argument, computes the checksum, and writes the 10-digit ISBN number. It's OK if the program doesn't write any leading 0s.

Solution in Python taking command line arguments. 1. Ramanujans taxi Problem. S.

Standard Book Numbering (SBN) D Check digit ISBN 81752576610 ISBN-10 Your output siyaofus-MacBook-Pro: homework 1 siyaofu$ python ISBN.py 030640615 The full ISBN number is 0306406152 siyaofus-MacBook-Pro: homework 1 siyaofu$ python ISBN.py 020 131452 The full ISBN number is 0201314525 siyaofus-MacBook-Pro: homework1 siyaofu$ Standard Book Numbering (SBN) D Check digit ISBN 81752576610 ISBN-10 Your output siyaofus-MacBook-Pro: homework 1 siyaofu$ python ISBN.py 030640615 The full ISBN number is 0306406152 siyaofus-MacBook-Pro: homework 1 siyaofu$ python ISBN.py 020 131452 The full ISBN number is 0201314525 siyaofus-MacBook-Pro: homework1 siyaofu$

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!