This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> // Bao gồm thư viện chuẩn | |
// Định nghĩa hàm tính giai thừa bằng đệ quy | |
long long tinhGiaiThua(int n) { | |
if (n < 0) { // Xử lý trường hợp đầu vào không hợp lệ | |
return -1; // Trả về -1 để báo lỗi | |
} | |
if (n == 0 || n == 1) { | |
return 1; // Giai thừa của 0 và 1 là 1 | |
} else { |