0
why in programming to find algorithms effectiveness and integer overflow we should use 10^9+7 modulus is their any reason ?
https://code.sololearn.com/c85JbqXldJcm/?ref=app Can anyone help in debugging the code it's not working properly
10 Answers
+ 6
Your recursive function fact always returns 1 so why bother with the recursion.
+ 5
WHY IS MODULO NEEDED...
The largest integer data type in C/C++ is the long long int; its size is 64 bits and can store integers from (-2^63) to (+2^63 -1). Integers as large as 9 x 10^18 can be stored in a long long int. But in certain problems, for instance when calculating the number of permutations of a size n array, even this large range may prove insufficient. We know that the number of permutations of a size n array is n! . Even for a small value of n, the answer can be very large. E.g., for n=21, the answer is 21! which is about 5 x 10^19 and too large for a long long int variable to store. This makes calculating values of large factorials difficult.
So, instead of asking the exact value of the answer, the problem setters ask the answer modulo some number M; so that the answer still remain in the range that can be stored easily in a variable.
+ 5
#2
Some languages such as Java and Python offer data types that are capable of storing infinitely large numbers. But data type size is not the only problem. As the size of the number increases the time required to perform mathematical operations on them also increases.
There are certain requirements on the choice of M:
1. It should just be large enough to fit
in an int data type.
2. It should be a prime number.
10^9 +7 fits both criteria;
+ 4
Your error message states you recurse too many times and used up the entire stack. This code might run on a PC as there would a larger area available, but SoloLearn only provides a small runtime environment. Your output of the call frames was interrupted due to hitting the execution time limit so you don't see all of them in your error message.
0
Remember one this that divide sign will simply divide the number, and modulas sign will give reminder of those numbers
0
Faisal bajwa I know about modulus I'm not talking about that why this number is used 10^7 +7 mod
0
Faisal bajwa John Wells sorry for ping you if you have free time please help me to fix above code
In this code in getting error can anyone solved this
https://code.sololearn.com/c85JbqXldJcm/?ref=app
0
Misha plz refer below article :
https://www.geeksforgeeks.org/modulo-1097-1000000007/
0
Ketan Lalcheta I need help for above linked code why that's not working
0
Misha sorry.. I m nt into Java nd could not be able to help or suggest you on it...