-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
37b1e1c
commit b684209
Showing
5 changed files
with
102 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#include <iostream> | ||
|
||
using namespace std; | ||
|
||
long giaithua(int n){ | ||
if (n==1){ | ||
return 1; | ||
} | ||
else{ | ||
return (n*giaithua(n-1)); | ||
} | ||
} | ||
|
||
int main(){ | ||
int a,b; | ||
cout << "Nhap so nguyen a: "; | ||
cin >> a; | ||
cout << "Nhap so nguyen b: "; | ||
cin >> b; | ||
float ans=(float)(giaithua(a)+giaithua(b))/giaithua(a+b); | ||
cout << "(a!+b!)/(a+b)! = " << ans << "\n"; | ||
return 0; | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#include <iostream> | ||
|
||
using namespace std; | ||
|
||
float f(float x, int n){ | ||
if (n==1) return x; | ||
else return (x/n*f(x,n-1)); | ||
} | ||
|
||
int main(){ | ||
float x; | ||
cout << "Nhap so thuc x: "; | ||
cin >> x; | ||
int n; | ||
cout << "Nhap so nguyen n: "; | ||
cin >> n; | ||
float ans=f(x,n); | ||
cout << "f(x,n) = " << ans << "\n"; | ||
return 0; | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#include <iostream> | ||
#include <math.h> | ||
|
||
using namespace std; | ||
|
||
float f(float x, int n){ | ||
if (n==0) return 2017; | ||
else return (pow(x,n)+f(x,n-1)); | ||
} | ||
|
||
int main(){ | ||
float x; | ||
cout << "Nhap so thuc x: "; | ||
cin >> x; | ||
int n; | ||
cout << "Nhap so nguyen n: "; | ||
cin >> n; | ||
float ans=f(x,n); | ||
cout << "f(x,n) = " << ans << "\n"; | ||
return 0; | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#include <iostream> | ||
|
||
using namespace std; | ||
|
||
int dem(int n){ | ||
if (n>=0 && n<=9) return 1; | ||
else return (dem(n/10)+1); | ||
} | ||
|
||
int main(){ | ||
int n; | ||
cout << "Nhap so nguyen n: "; | ||
cin >> n; | ||
cout << "So nguyen " << n << " co " << dem(n) << " chu so.\n"; | ||
return 0; | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#include <iostream> | ||
|
||
using namespace std; | ||
|
||
int catalan(int n){ | ||
if (n==1 || n==2) return 1; | ||
else{ | ||
int t=0; | ||
for (int i=0;i<n;i++){ | ||
t+=catalan(i)*catalan(n-i); | ||
} | ||
return t; | ||
} | ||
} | ||
|
||
int main(){ | ||
int n; | ||
cout << "Nhap so nguyen duong n: "; | ||
cin >> n; | ||
cout << "Chu so CataLan thu " << n << " la " << catalan(n) << "\n"; | ||
return 0; | ||
} |