Write a program that will take a number N as input and print the factorial of all numbers from 1 to K
Number factorial
1 1
2 2
3 6
I I
I I
I I
N N1
Answers
Answered by
3
Answer:
Explanation:
import java.util.*;
class prog
{
public static void main(String args[])
{
Scanner sc=new Scanner(System.in);
int k=0;
System.out.println("Enter The value of N=");
int n=sc.nextInt();
for(int i=1;i<=n;i++)
{
k=factorial(i);
System.out.println(n+" "+k);
}
}
int factorial( int a)
{
int p=1;
for(int j=1;j<=a;j++)
{
p*=i;
}
return p;
}
}
#answerwithquality & #BAL
Similar questions
English,
6 months ago
English,
6 months ago
English,
6 months ago
English,
1 year ago
Science,
1 year ago
Psychology,
1 year ago
Math,
1 year ago
Computer Science,
1 year ago