
Sum of numbers, Factorial, and LCM
1)Sum of first n numbers Flowchart Python sum = 0 no = 1 while no <= 10 : sum = sum + no no = no + 1 print ( " Sum = " , sum ) Output Javascript let sum = 0 ; let no = 1 ; while ( no <= 10 ) { sum = sum + no ; no = no + 1 ; } console . log ( " Sum = " , sum ); Java public class SumOfNumbers { public static void main ( String [] args ) { int sum = 0 ; int no = 1 ; while ( no <= 10 ) { sum = sum + no ; no = no + 1 ; } System . out . println ( "Sum = " + sum ); } } 2)Factorial of a number Flowchart Python fact = 1 no = 1 while no <= 5 : fact = fact * no no = no + 1 print ( " Factorial = " , fact ) Output Javascript let fact = 1 ; let no = 1 ; while ( no <= 5 ) { fact = fact * no ; no = no + 1 ; } console . log ( " Factorial = " , fact ); Java public class FactorialExample { public static void main ( String [] args ) { int fact = 1 ; int no = 1 ; while ( no <= 10 ) { fact = fact * no ; no = no + 1 ; } System . out . println ( "Factorial = " + fact ); } } 3)Least Common Multiple(LCM) Flowch
Continue reading on Dev.to Python
Opens in a new tab



