Input a Number and Print the Following 1*2*3*4*5*6......*n
Input a Number and Print the Following 1*2*3*4*5*6......*n
Input a Number and Print the Following 1*2*3*4*5*6......*n
//Example for multiplication of a digit.
package r4r.co.in;
import java.io.*;
public class NewClass {
public static void main(String[] args) throws IOException {
BufferedReader digit = new BufferedReader(new InputStreamReader(System.in));
System.out.println("Enter the digit:");
String s1 = digit.readLine();
int n1 = Integer.parseInt(s1);
//Multiplication code
String p = "";
for (int i = 1; i <= n1; i++) {
if (i == 1) {
p = "" + i;
} else {
p = p + "*" + i;
}
}
System.out.println("The multiplication from 1 to Digit:" + n1 + "=" + p);
}
}
Enter the digit:
12
The multiplication from 1 to Digit:12=1*2*3*4*5*6*7*8*9*10*11*12