My Blog

My WordPress Blog

My Blog

My WordPress Blog

Factorial of a Number:

public class Factorial {

 public static void main(String[] args) {

 int num = 5, factorial = 1;

 for(int i = 1; i <= num; ++i) {

 factorial *= i;

 }

 System.out.println(“Factorial of ” + num + ” is: ” + factorial);

 }

Output:

Factorial of 5 is: 120
Factorial of a Number:

Leave a Reply

Your email address will not be published. Required fields are marked *

Scroll to top