We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents 4986f7c + 0a18b33 commit c0369caCopy full SHA for c0369ca
1 file changed
Basic Codes/factorial-by-loops.java
@@ -0,0 +1,25 @@
1
+//Question: You have to make an algorithm to find factorial of a given number;
2
+
3
+//factorial of n is n*(n-1)*.....*2*1;
4
+package com.company;
5
6
+import java.util.Scanner;
7
8
+public class Factorial {
9
+ public Factorial() {
10
+ }
11
12
+ public static void main(String[] args) {
13
+ Scanner in = new Scanner(System.in);
14
+ System.out.println("you want factorial of which number");
15
16
+ //input of given number
17
+ int n = in.nextInt();
18
+ int fact = 1;
19
+ for(int i = n; 1 <= i; --i) {
20
+ fact *= i;
21
22
23
+ System.out.println("the factorial of " + n + " is " + fact);
24
25
+}
0 commit comments