Alternatives
Members may post updates or alternatives to this current article in order to show different
approaches or add new features.
Can we simplify it by: (This essentially passes only two numbers). public int GCD(int value1, int value2){ int max = 0; bool gcdFound = false; int counter = 1; //Make sure both numbers are atleast 2 or above if (( value1 <= 1 ) || (value2 <= 1)) return...
/// /// Find the Greatest Common Divisor /// /// Number a /// Number b /// The greatest common Divisor public static long GCD(long a, long b) ...
18 Feb 2011Mauro Leggieri
It is better to do this:public static long LCM(long a, long b){ return (a / GCD(a,b)) * b;}To avoid overflow on big numbers.
Dr. Alexander Bell (aka DrABell), a seasoned full-stack DevOps and Data Engineer holds PhD in Electrical and Computer Engineering, authored 37 inventions and published 100+ technical articles, including those popular at CodeProject totaling 4M+ views. Alex pioneered AI/NLP, Cloud development, .NET/Java technology stacks, advanced SQL extensions, HTML5/CSS3 and other important Web technologies; developed multiple award-winning Web/Win apps submitted to App Innovation Contests (AIC 2012/2013). Currently focused on Microsoft Azure Cloud and GitHub Copilot AI-enabled DevOps.
- Quiz Engine powered by Azure Cloud (Dev Challenge article)
- 'enRoute': Real-time NY City Bus Tracking Web App (IoT on Azure)
- Azure web app: Engineering Calculator VOLTMATTER
- Azure: NYC real-time bus tracking app
- HTML5/CSS3 graphic enhancement: buttons, inputs
- Aggregate Product function extends SQL
- HTML5 Tables Formatting: Alternate Rows, Color Gradients, Shadows
- YouTube™ API for ASP.NET