Factors
View as PDFYou are given two positive integers, and
. How many factors does the sum of the integers from
to
inclusive have?
Input Specification
The input contains one line with two space-separated integers, and
.
Output Specification
Output a single integer, the number of factors of the sum of the integers from to
inclusive.
Constraints
Sample Input
1 3
Sample Output
4
Comments
Hint: there is integer overflow using 64 bits when you add all integers together. Plus factoring the sum of all integers summed up is too slow O(square root of the sum) which can be as high as 10^25. Try to find another way to do this.
Can anyone help me with test case 4? 48 is marked as incorrect, but I don't understand why.
The input is
1 1000000000000. The sum of the numbers in between should be1001882602603448320. I have calculated its factors to be the following.1,10018826026034483202,5009413013017241604,2504706506508620805,2003765205206896648,12523532532543104010,10018826026034483216,6261766266271552020,5009413013017241632,3130883133135776040,2504706506508620864,1565441566567888080,12523532532543104128,7827207832839440160,6261766266271552256,3913603916419720320,3130883133135776512,1956801958209860640,15654415665678881024,9784009791049301280,7827207832839442048,4892004895524652560,3913603916419725120,19568019582098610240,97840097910493This makes for 24 pairs, or 48 total individual factors. Alternatively, the number of factors can be calculated through prime numbers. I have calculated the prime factorisation of to be
(2^11)(5^1)(97840097910493^1). Taking the exponents of each, you can deduce that the number of factors should be(11 + 1)(1 + 1)(1 + 1), which is equal to 48.What am I overlooking?
What is the sum of the first
positive integers? Please show your work.
I was using the formula
on a separate program I made, but having redone the calculation separately, my program didn't get it right. Thanks.
I am at the same place where you were before. But how did you get out?
In test case 4,
,
, I got sum(A,B) = 1001882602603448320. and the answer is 48.
Thanks.