
imagetitle | keyword
multiplication 3 digit by 1 digit
We are accustomed two numbers A and B such that B >= A. We charge to compute the aftermost chiffre of this consistent F such that F = B!/A! area 1 = A, B <= 10^18 (A and B are actual large).
Examples:
As we know, factorial action grows on an exponential rate. Even the better abstracts typecannot authority factorial of numbers like 100. To compute factorial of moderately ample numbers, accredit this.Here the accustomed constraints are actual large. Thus, artful the two factorials and laterdividing them and accretion the aftermost chiffre is about an absurd task.
Thus we accept to acquisition an alternating access to breach bottomward our problem. It is accepted that the aftermost chiffre of factorial consistently belongs to the set {0, 1, 2, 4, 6}The access is as follows: –1) We appraise the aberration amid B and A2) If the (B – A) >= 5, again the acknowledgment is consistently 03) If the aberration (B – A) < 5, again we iterate from (A 1) to B, accumulate and abundance them. multiplication_answer % 10 shall be our answer.
Output:
This commodity is contributed by Shivani Mittal. If you like GeeksforGeeks and would like to contribute, you can additionally address an commodity application contribute.geeksforgeeks.org or mail your commodity to contribute@geeksforgeeks.org. See your commodity actualization on the GeeksforGeeks capital folio and advice added Geeks.
Please address comments if you acquisition annihilation incorrect, or you appetite to allotment added advice about the affair discussed above.




