Skip to content
This repository has been archived by the owner on Feb 15, 2024. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
NTGNguyen committed Nov 13, 2023
2 parents adc9146 + eaca53b commit 02fa83c
Show file tree
Hide file tree
Showing 40 changed files with 1,544 additions and 348 deletions.
20 changes: 18 additions & 2 deletions Bai001/Source.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,24 @@
#include <iostream>
#include <iostream>;

using namespace std;

int Tong(int);

int Tong(int n)
{
if (n == 0)
return 0;
int s = Tong(n - 1);
return (s + n * n);
}

int main()
{
int k;
cout << "Nhap n: ";
cin >> k;

return 0;
int kq = Tong(k);
cout << "S(" << k << ")= " << kq;
return 1;
}
15 changes: 14 additions & 1 deletion Bai006/Source.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,21 @@
#include <iostream>
#include <iomanip>
using namespace std;

float Tong(int);

int main()
{

int n;
cout << "Nhap n: ";
cin >> n;
cout << "\nKet qua cua S(" << n << ") la: " << setw(5) << setprecision(5) << Tong(n) << endl;
return 0;
}

float Tong(int n) {
if (n == 0) {
return 0;
}
return Tong(n - 1) + (float)n / (n + 1);
}
23 changes: 22 additions & 1 deletion Bai011/Source.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,29 @@
#include <iostream>
#include <limits>
#include <iomanip>
#include <cmath>
using namespace std;

int sum(int);

int main()
{
int n;
cout << "\nEnter the value of n: ";
cin >> n;
while (n > INT_MAX || n < 0)
{
cout << "The inputted value of n is invalid. Please re-enter the value of n." << endl;
cout << "\nEnter the value of n: ";
cin >> n;
}
cout << "\nThe result of S(" << n << ") is: " << sum(n) << "." << endl;
return 0;
}

return 0;
int sum(int n)
{
if (n == 0)
return 0;
return (sum(n - 1) + pow(n,4));
}
15 changes: 14 additions & 1 deletion Bai016/Source.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,21 @@
#include <iostream>
using namespace std;

float Tong(int);

int main()
{
int k;
cout << "Nhap so nguyen: ";
cin >> k;
float kq = Tong(k);
cout << "Tong la: " << kq;
return 1;
}

return 0;
float Tong(int n)
{
if (n == 0)
return 0;
return (Tong(n - 1) + (float)1 / (n * (n + 1) * (n + 2)));
}
17 changes: 16 additions & 1 deletion Bai021/Source.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,23 @@
#include <iostream>
using namespace std;

float Tong(float, int);

int main()
{
int k;
float y;
cout << "Nhap so nguyen: ";
cin >> k;
cin >> y;
float kq = Tong(y, k);
cout << "Ket qua la: " << kq;
return 1;
}

return 0;
float Tong(float x, int n)
{
if (n == 0)
return x;
return (Tong(x, n - 1) * (x + n));
}
19 changes: 15 additions & 4 deletions Bai026/Source.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,19 @@
#include <iostream>
#include<iostream>
#include<cmath>
using namespace std;

float sum(int);
int main()
{

return 0;
int n;
cin >> n;
float kq = sum(n);
cout << kq;
return 0;

}
float sum(int n)
{
if (n == 0)
return 0;
return sqrt(n + sum(n - 1));
}
17 changes: 16 additions & 1 deletion Bai031/Source.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,23 @@
#include <iostream>

using namespace std;

int TinhAn(int);

int TinhAn(int n)
{
if (n == 1)
return -2;
return 5 * TinhAn(n - 1) + 12;
}

int main()
{
int k;
cout << "Nhap n: ";
cin >> k;

return 0;
int kq = TinhAn(k);
cout << "Ket qua la: " << kq;
return 1;
}
24 changes: 23 additions & 1 deletion Bai036/Source.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,30 @@
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;

float Dem_so_le(int);

int main()
{

int n;
cout << "Nhap n: ";
cin >> n;
cout << "\nKet qua cua S(" << n << ") la: " << setw(5) << setprecision(5) << Dem_so_le(n) << endl;
return 0;
}

float Dem_so_le(int n) {
n = abs(n);
if (n <= 9) {
if (n % 2 == 1) {
return 1;
}
return 0;
}
int dv = n % 10;
if (dv % 2 == 1) {
return Dem_so_le(n / 10) + 1;
}
return Dem_so_le(n / 10);
}
33 changes: 32 additions & 1 deletion Bai041/Source.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,39 @@
#include <iostream>
#include <limits>
#include <iomanip>
using namespace std;

bool EvenExisted(int);

int main()
{
int n;
cout << "\nEnter the value of n: ";
cin >> n;
while (n > INT_MAX || n < 0)
{
cout << "The inputted value of n is invalid. Please re-enter the value of n." << endl;
cout << "\nEnter the value of n: ";
cin >> n;
}
if (EvenExisted(n) == true)
cout << "\nIn the number " << n << " exists even digits." << endl;
else
cout << "\n In the number " << n << " doesn't exists even digits." << endl;
cout << endl;
return 0;
}

return 0;
bool EvenExisted(int n)
{
n = abs(n);
if (n <= 9)
{
if (n % 2 == 0)
return true;
return false;
}
int unit = n % 10;
if (unit % 2 == 0)
return true;
}
24 changes: 21 additions & 3 deletions Bai046/Source.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,26 @@
#include <iostream>
#include<iostream>
using namespace std;

long long a(int);
long long b(int);
int main()
{

int n;
cin >> n;
long long kq = a(n);
long long kq2 = b(n);
cout << kq << " " << kq2;
return 0;
}
long long a(int n)
{
if (n == 1)
return 2;
return 3 * b(n - 1) + 2 * a(n - 1);

}
long long b(int n)
{
if (n == 1)
return 1;
return a(n - 1) + 3 * b(n - 1);
}
19 changes: 18 additions & 1 deletion Bai051/Source.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,25 @@
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;

int S(int);

int main()
{

int n;
cout << "Nhap n: ";
cin >> n;
cout << "\nKet qua cua S(" << n << ") la: " << setw(5) << S(n) << endl;
return 0;
}

int S(int n) {
if (n == 0) {
return 0;
}
if (n == 1) {
return 1;
}
return (1 + n) * S(n - 1) - n * S(n - 2);
}
26 changes: 25 additions & 1 deletion Bai056/Source.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,32 @@
#include <iostream>
#include <limits>
#include <iomanip>
using namespace std;

float sum(int);

int main()
{
int n;
cout << "\nEnter the value of n: ";
cin >> n;
while (n > INT_MAX || n < 0)
{
cout << "The inputted value of n is invalid. Please re-enter the value of n." << endl;
cout << "\nEnter the value of n: ";
cin >> n;
}
cout << "\nThe result of S(" << n << ") is: " << setw(5) << setprecision(5) << sum(n) << "." << endl;
return 0;
}

return 0;
float sum(int n)
{
if (n == 0)
return 0;
if (n == 1)
return 1;
float a = sum(n - 1);
float b = sum(n - 2);
return (a + (float)1 /(n + 1 / (a - b)));
}
Loading

0 comments on commit 02fa83c

Please sign in to comment.