Write a java program that prints the factorial of a positive integer. In mathema
ID: 3639804 • Letter: W
Question
Write a java program that prints the factorial of a positive integer. In mathematics, the factorial of a non-negative integer n. denoted by n!, is the product of all positive integers less than or equal to n. For example, 6! = 6 Times 5 Times 4 Times 3 Times 2 Times 1 = 720 The output of the program should look as shown below: Write a java program for the requirements given below: The java application should be able to print a multiplication table for the numbers as input by the user. The application should ask the user to enter an integer up to which the multiplication tables are required. The output should look like as shown below:Explanation / Answer
please rate - thanks
CRAMSTER rule is 1 question per post, but they're easy, so OK
import java.util.*;
public class factorial
{public static void main(String[] args)
{
int nf=1,i,n;
Scanner in=new Scanner(System.in);
System.out.println("Enter a positive integer for which you need factorial:");
n=in.nextInt();
for(i=1;i<=n;i++)
nf*=i;
System.out.println("The factorial of "+n+" is "+nf);
}
}
---------------------------------------
import java.util.*;
public class multTable
{
public static void main(String [] args)
{int i,j,n;
Scanner in=new Scanner(System.in);
System.out.println("Enter a positive integer up to which the multiplication is required:");
n=in.nextInt();
System.out.println("Multiplication tables up to "+n+" are given below");
for(i=1;i<=n;i++)
{for(j=1;j<=10;j++)
System.out.print(i*j+" ");
System.out.println();
}
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.