import java.util.Scanner;
public class Main{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int a = sc.nextInt();
int count = 1;
for(int i = 1;i<=a;i++){
count *=i;
System.out.println(i+" = "+count);
}
}
}
so here it forms a for loop and i starts from 1 to input value a has firstly count = 1, and count value is 1 and for 1st loop run value of count = 1*1 = 1 As in the statement count*=i it says(count = count *i) as so for 2nd loop run i value is 2 so count=1*2=2 and so on........ i hope you get it if else feel free to ask me i will assist you!! :)
Top comments (0)