Sunday, 4 June 2023

GCD/HCF optimized

How to calculate GCD/HCF with optimization.

Step 1 : Calculate Remainder between A and B.

Step 2 : Change A with B and B with remainder obtained

Step 3 : Do this recursively till we get B as 0

 

Note : A > B, if its not the case then change B and A.

Code :










No comments:

Post a Comment

Count of digits in factorial

 To count the digits in a factorial we must seek some optimization as you might also understand that getting all the product and storing the...