
LCM, Sum of N Numbers & Factorial with Flowcharts
What is LCM? The Least Common Multiple (LCM) of two numbers is the smallest number that is divisible by both numbers. Example: LCM of 3 and 10 = 30 Because 30 is the smallest number divisible by both 3 and 10. Flowchart Python Code no1 = 3 no2 = 10 big = no1 if no1 > no2 else no2 big2 = big while True : if big % no1 == 0 and big % no2 == 0 : print ( " LCM is " , big ) break big += big2 JavaScript Code let no1 = 3 ; let no2 = 10 ; let big = ( no1 > no2 ) ? no1 : no2 ; let big2 = big ; while ( true ) { if ( big % no1 === 0 && big % no2 === 0 ) { console . log ( " LCM is " + big ); break ; } big += big2 ; } Java Code public class LCM { public static void main ( String [] args ) { int no1 = 3 ; int no2 = 10 ; int big = ( no1 > no2 ) ? no1 : no2 ; int big2 = big ; while ( true ) { if ( big % no1 == 0 && big % no2 == 0 ) { System . out . println ( "LCM is " + big ); break ; } big += big2 ; } } } Output Sum of First N Numbers Using Flowchart (Python, Java, JavaScript) Flowchart Python Code ba
Continue reading on Dev.to Python
Opens in a new tab


