Thursday 23 June 2016

HERE WE GOES AFTER A LONG TIME A SMALL PROGRAM TO THE FUTURE GENERATORS

You have to print the sum of divisors of all the numbers from 1 to n.

It’s super fast when you know the trick but you have to find it.
For example if n=4, lets define d(n) the set of the divisors of n:
* d(1)={1},
* d(2)={1,2},
* d(3)={1,3},
* d(4)={1,2,4}.
And their sum is 1+1+2+1+3+1+2+4=15.
Look carefully at the divisors to find the trick.

COMMENT YOUR CODE. ANSWERS WILL BE POSTED IN FEW DAYS

No comments:

Post a Comment