Write a program in java to calculate and display the factorials of all the numbers between 'm' and 'n' (where m0, n>0). [ with Bufferreader
Answers
Answered by
0
Answer:
import java.util.Scanner;
public class KboatFactRange
{
public static void main(String args[]) {
Scanner in = new Scanner(System.in);
System.out.print("Enter m: ");
int m = in.nextInt();
System.out.print("Enter n: ");
int n = in.nextInt();
if (m < n && m > 0 && n > 0) {
for (int i = m; i <= n; i++) {
long fact = 1;
for (int j = 1; j <= i; j++)
fact *= j;
System.out.println("Factorial of " + i + " = " + fact);
}
}
else {
System.out.println("Invalid Input");
}
}
}
Similar questions
Environmental Sciences,
2 hours ago
Chemistry,
2 hours ago
Biology,
2 hours ago
Science,
4 hours ago
Biology,
7 months ago