DEV Community

S Sarumathi
S Sarumathi

Posted on

Factorial

1. Factorial:
Flowchart:

Java Script:
Program:

let fact = 1;
let no = 1;

while (no <= 10) {
    fact = fact * no;
    no = no + 1;
}

console.log(fact);
Enter fullscreen mode Exit fullscreen mode

Output:

Java:
Program:

public class Main {
    public static void main(String[] args) {
        int fact = 1;
        int no = 1;

        while (no <= 10) {
            fact = fact * no;
            no = no + 1;
        }

        System.out.println(fact);
    }
}
Enter fullscreen mode Exit fullscreen mode

Python:
Program:

fact = 1
no = 1

while no <= 10:
    fact = fact * no
    no = no + 1

print(fact)
Enter fullscreen mode Exit fullscreen mode

Top comments (0)