Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
- package D31_8;
- import java.util.Scanner;
- /**
- *
- * @author Administrator
- */
- public class De_Qui {
- public static void main(String[] args) {
- Scanner input = new Scanner(System.in);
- System.out.print("Nhap n : ");
- int n = input.nextInt();
- System.out.println("Ket qua : " + De_Qui.Giai_Thua(n));
- De_Qui dequi = new De_Qui();
- System.out.println("Ket qua : " + dequi.Giai_Thua_nonStatic(n));
- }
- public static long Giai_Thua(int n) {
- if (n == 0) {
- return 1;
- } else {
- return n * Giai_Thua(n - 1);
- }
- }
- public long Giai_Thua_nonStatic(int n) {
- if (n == 0) {
- return 1;
- } else {
- return n * Giai_Thua_nonStatic(n - 1);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement