Day 35 & 36: Looping Demo of Factorial and LCM

What is factorial in Java programming? In Java programming, a factorial is the mathematical operation of finding the product of all positive integers up to a given number nnn package demo_programs; public class Looping{ public static void main(String[] args) { // TODO Auto-generated method stub Looping l = new Looping(); l.find_factorial(4); } private void find_factorial(int no) { // TODO Auto-generated method stub int factorial=1; while (no>=1){ factorial=factorial*no; no=no-1; } System.out.println(factorial); } } lead code programming package demo_programs; public class Looping2 { public static void main(String[] args) { // TODO Auto-generated method stub int choco=15; int wrapper=15; while (wrapper>=3){ wrapper =wrapper -3; choco=choco+1; wrapper = wrapper+1; } System.out.println("The total number of choco is "+choco); } }

May 4, 2025 - 18:41
 0
Day 35 & 36: Looping Demo of Factorial and LCM

What is factorial in Java programming?

In Java programming, a factorial is the mathematical operation of finding the product of all positive integers up to a given number nnn

package demo_programs;

public class Looping{

    public static void main(String[] args) {
        // TODO Auto-generated method stub
         Looping l = new Looping();
         l.find_factorial(4);

    }

    private void find_factorial(int no) {
        // TODO Auto-generated method stub
        int factorial=1;
        while (no>=1){
            factorial=factorial*no;
            no=no-1;
        }   
        System.out.println(factorial);

    }
}

lead code programming

package demo_programs;

public class Looping2 {

    public static void main(String[] args) {
        // TODO Auto-generated method stub
         int choco=15;
         int wrapper=15;
         while (wrapper>=3){
             wrapper =wrapper -3;
             choco=choco+1;
             wrapper = wrapper+1;

         }
        System.out.println("The total number of choco is "+choco);  
    }
}