by @Wichart Manachaimongkol Fork
 
id_874658b8_7c03_417b_8b51_4ef7b5283229 Begin id_35ca9b2a_2e10_4d31_91c4_dfeb93086752 x = 0 id_874658b8_7c03_417b_8b51_4ef7b5283229:s->id_35ca9b2a_2e10_4d31_91c4_dfeb93086752:n id_0f2cdd4b_dcbe_43ca_9c4a_2514bd550923 x id_35ca9b2a_2e10_4d31_91c4_dfeb93086752:s->id_0f2cdd4b_dcbe_43ca_9c4a_2514bd550923:n id_94849c02_d43c_49c8_94dc_bcf1ae5ab3b4 "" + x + "! = " + Fact(x) id_0f2cdd4b_dcbe_43ca_9c4a_2514bd550923:s->id_94849c02_d43c_49c8_94dc_bcf1ae5ab3b4:n id_c0a76116_ad05_45ed_bc8a_6aec674efbf8 End id_94849c02_d43c_49c8_94dc_bcf1ae5ab3b4:s->id_c0a76116_ad05_45ed_bc8a_6aec674efbf8:n
import java.util.*;

public class FunctionExercise5 {
  static Scanner scanner = new Scanner(System.in);

  public static void main(String args[]) {
    int x = 0;
    System.out.print("Please enter a number : ");
    x = scanner.nextInt();
    System.out.println("" + x + "! = " + Fact(x));
  }

  public static int Fact(int p1) {
    int RetVal = 0;
    if (p1 > 0) {
      RetVal = Fact(p1 - 1) * p1;
    } else {
      RetVal = 1;
    }
    return RetVal;
  }
}