DEV Community

AmalaReegan
AmalaReegan

Posted on

Day 28-Factorial Number:

Factorial:

==> Factorial of a non-negative integer, is multiplication of all integers smaller than or equal to n

Image description

Example Program:

package day1; import java.util.Scanner; public class Factorial { public static void main(String[] args) { Scanner scan=new Scanner(System.in); System.out.println("Enter the factorial number"); int n=scan.nextInt(); long Factorial=1; for(int i=1; i<=n; i++) { Factorial=Factorial*i; } System.out.println(Factorial); } } 
Enter fullscreen mode Exit fullscreen mode

Output:

Image description

Top comments (0)