URI Problem (Simple Factorial) 1153:
Simple Factorial is a basic problem on URI online judge for novice problem solver.
You can find details on this Link.
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
* @Author : Muhammad Harun-Or-Roshid
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
String value = br.readLine().trim();
int x = Integer.valueOf(value);
bw.write(getFactorial(x)+"\n");
private static int getFactorial(int x) {
return x * getFactorial(x - 1);
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
/**
* @Author : Muhammad Harun-Or-Roshid
* @Date : Oct 21, 2016
* @Time : 10:08:20 PM
*/
public class Uri1153 {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
String value = br.readLine().trim();
int x = Integer.valueOf(value);
if (x > 0 && x < 13) {
bw.write(getFactorial(x)+"\n");
bw.flush();
}
bw.close();
br.close();
}
private static int getFactorial(int x) {
if (x == 1) {
return 1;
} else {
return x * getFactorial(x - 1);
}
}
}
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
/**
* @Author : Muhammad Harun-Or-Roshid
* @Date : Oct 21, 2016
* @Time : 10:08:20 PM
*/
public class Uri1153 {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
String value = br.readLine().trim();
int x = Integer.valueOf(value);
if (x > 0 && x < 13) {
bw.write(getFactorial(x)+"\n");
bw.flush();
}
bw.close();
br.close();
}
private static int getFactorial(int x) {
if (x == 1) {
return 1;
} else {
return x * getFactorial(x - 1);
}
}
}