import java.util.*; public class Factotial { public static void main(String[] args) { Scanner s = new Scanner(System.in); System.out.println("\n Enter Number..."); int number = s.nextInt(); int fact=1; for(int i=1;i<=number;i++) { fact=fact*i; } System.out.println("\n Factorial of "+number+" is = "+fact); } } Output: Enter Number... 3 Factorial of 3 is = 6
Basic Java programs. All programs done in very simple ways. It helps beginners to grow their programming skills and build a programming logic.
Monday, 7 December 2020
Factorial of Number using For Loop
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment
If you have any doubts, please let me know