Given the value of a block in grams as input, write a program that would print the largest possible currency value that you can receive as the output. Assume that the maximum value of a block that can be given as an input is 1,000,000,000 grams and the minimum value is 2 grams.
Sample input:
12
Sample output:
13
Explanation: You can change 12 into blocks of 12/2 = 6, 12/3 = 4 and 12/4 = 3, and then exchange these for 6 + 4 + 3 = 13 units of currency3
Sample input:
2
Sample output:
2
Explanation: If you exchange 2 grams into smaller blocks, it gives 2/2 = 1, 2/3 = 0, 2/4 = 0, only 1 unit. Instead, you can directly exchange the block for 2 units of currency.
Sanjay SabariyaPosted Oct 15, 2015, 8:01 AM
utkrisht srivastavPosted Oct 15, 2015, 7:45 AM
Sanjay SabariyaPosted Oct 15, 2015, 6:34 AM