Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
d95e087
physics: bernoulli's theorem
twilight-debugger Feb 24, 2026
af94fb7
physics: kirchoff's law
twilight-debugger Feb 24, 2026
2989264
physics: polarisation of light
twilight-debugger Feb 24, 2026
9f50117
physics: brewsters_law.cpp
twilight-debugger Feb 25, 2026
00fe5d3
Rename rect_perimeter to rectangle_perimeter
twilight-debugger Feb 27, 2026
49c1fbf
Merge pull request #1 from twilight-debugger/twilight-debugger-patch-1
twilight-debugger Feb 27, 2026
00b97fe
Rename members and update Complex class methods
twilight-debugger Feb 27, 2026
3589f4a
Merge pull request #2 from twilight-debugger/twilight-debugger-patch-2
twilight-debugger Feb 27, 2026
2db6a07
Add formulas to area calculation functions
twilight-debugger Mar 1, 2026
3163937
Merge pull request #3 from twilight-debugger/twilight-debugger-patch-3
twilight-debugger Mar 1, 2026
0e5429d
Refactor is_factorial function parameter name
twilight-debugger Mar 1, 2026
2bc8b7b
Merge pull request #4 from twilight-debugger/twilight-debugger-patch-4
twilight-debugger Mar 1, 2026
360238d
Rename parameter in factorial function
twilight-debugger Mar 1, 2026
b744e0f
Merge pull request #5 from twilight-debugger/twilight-debugger-patch-5
twilight-debugger Mar 1, 2026
565bbf2
Rename parameter in fibonacci function
twilight-debugger Mar 1, 2026
03646f0
Merge pull request #6 from twilight-debugger/twilight-debugger-patch-6
twilight-debugger Mar 1, 2026
b03b58b
Refactor parameter names in digit counting functions
twilight-debugger Mar 1, 2026
b904508
Merge pull request #7 from twilight-debugger/twilight-debugger-patch-7
twilight-debugger Mar 1, 2026
a78b69c
Add comments to volume calculation functions
twilight-debugger Mar 1, 2026
95fffc3
Merge pull request #8 from twilight-debugger/twilight-debugger-patch-8
twilight-debugger Mar 1, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 20 additions & 20 deletions math/area.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ namespace math {
*/
template <typename T>
T square_area(T length) {
return length * length;
return length * length; // A = l^2 -> SQUARE
}

/**
Expand All @@ -38,7 +38,7 @@ T square_area(T length) {
*/
template <typename T>
T rect_area(T length, T width) {
return length * width;
return length * width; // A = l(b) -> RECTANGLE
}

/**
Expand All @@ -50,7 +50,7 @@ T rect_area(T length, T width) {
*/
template <typename T>
T triangle_area(T base, T height) {
return base * height / 2;
return base * height / 2; // A = b(h) /2 -> TRIANGLE
}

/**
Expand All @@ -61,7 +61,7 @@ T triangle_area(T base, T height) {
*/
template <typename T>
T circle_area(T radius) {
return M_PI * pow(radius, 2);
return M_PI * pow(radius, 2); // A = pi (r^2) -> CIRCLE
}

/**
Expand All @@ -73,7 +73,7 @@ T circle_area(T radius) {
*/
template <typename T>
T parallelogram_area(T base, T height) {
return base * height;
return base * height; // A = b(h) -> PARALLELOGRAM
}

/**
Expand All @@ -84,7 +84,7 @@ T parallelogram_area(T base, T height) {
*/
template <typename T>
T cube_surface_area(T length) {
return 6 * length * length;
return 6 * length * length; // A = 6(l)(b) -> CUBE
}

/**
Expand All @@ -95,7 +95,7 @@ T cube_surface_area(T length) {
*/
template <typename T>
T sphere_surface_area(T radius) {
return 4 * M_PI * pow(radius, 2);
return 4 * M_PI * pow(radius, 2); // A = 4 * pi (r^2) -> SPHERE
}

/**
Expand All @@ -107,7 +107,7 @@ T sphere_surface_area(T radius) {
*/
template <typename T>
T cylinder_surface_area(T radius, T height) {
return 2 * M_PI * radius * height + 2 * M_PI * pow(radius, 2);
return 2 * M_PI * radius * height + 2 * M_PI * pow(radius, 2); // A = 2 * pi * r * h + 2 * pi * (r^2) -> CYLINDER
}

/**
Expand All @@ -119,7 +119,7 @@ T cylinder_surface_area(T radius, T height) {
*/
template <typename T>
T hemi_sphere_surface_area(T radius) {
return 3 * M_PI * pow(radius, 2);
return 3 * M_PI * pow(radius, 2); // A = 3 * pi * (r^2)
}
} // namespace math

Expand Down Expand Up @@ -157,7 +157,7 @@ static void test() {
std::cout << "Expected Output: " << int_expected << std::endl;
std::cout << "Output: " << int_area << std::endl;
assert(int_area == int_expected);
std::cout << "TEST PASSED" << std::endl << std::endl;
std::cout << "TEST PASSED!" << std::endl << std::endl;

// 2nd test
float_length = 2.5;
Expand All @@ -169,7 +169,7 @@ static void test() {
std::cout << "Expected Output: " << float_expected << std::endl;
std::cout << "Output: " << float_area << std::endl;
assert(float_area == float_expected);
std::cout << "TEST PASSED" << std::endl << std::endl;
std::cout << "TEST PASSED!" << std::endl << std::endl;

// 3rd test
int_length = 4;
Expand All @@ -183,7 +183,7 @@ static void test() {
std::cout << "Expected Output: " << int_expected << std::endl;
std::cout << "Output: " << int_area << std::endl;
assert(int_area == int_expected);
std::cout << "TEST PASSED" << std::endl << std::endl;
std::cout << "TEST PASSED!" << std::endl << std::endl;

// 4th test
double_length = 2.5;
Expand All @@ -197,7 +197,7 @@ static void test() {
std::cout << "Expected Output: " << double_expected << std::endl;
std::cout << "Output: " << double_area << std::endl;
assert(double_area == double_expected);
std::cout << "TEST PASSED" << std::endl << std::endl;
std::cout << "TEST PASSED!" << std::endl << std::endl;

// 5th test
int_base = 10;
Expand All @@ -211,7 +211,7 @@ static void test() {
std::cout << "Expected Output: " << int_expected << std::endl;
std::cout << "Output: " << int_area << std::endl;
assert(int_area == int_expected);
std::cout << "TEST PASSED" << std::endl << std::endl;
std::cout << "TEST PASSED!" << std::endl << std::endl;

// 6th test
double_radius = 6;
Expand All @@ -225,7 +225,7 @@ static void test() {
std::cout << "Expected Output: " << double_expected << std::endl;
std::cout << "Output: " << double_area << std::endl;
assert(double_area == double_expected);
std::cout << "TEST PASSED" << std::endl << std::endl;
std::cout << "TEST PASSED!" << std::endl << std::endl;

// 7th test
int_base = 6;
Expand All @@ -239,7 +239,7 @@ static void test() {
std::cout << "Expected Output: " << int_expected << std::endl;
std::cout << "Output: " << int_area << std::endl;
assert(int_area == int_expected);
std::cout << "TEST PASSED" << std::endl << std::endl;
std::cout << "TEST PASSED!" << std::endl << std::endl;

// 8th test
double_length = 5.5;
Expand All @@ -251,7 +251,7 @@ static void test() {
std::cout << "Expected Output: " << double_expected << std::endl;
std::cout << "Output: " << double_area << std::endl;
assert(double_area == double_expected);
std::cout << "TEST PASSED" << std::endl << std::endl;
std::cout << "TEST PASSED!" << std::endl << std::endl;

// 9th test
double_radius = 10.0;
Expand All @@ -264,7 +264,7 @@ static void test() {
std::cout << "Expected Output: " << double_expected << std::endl;
std::cout << "Output: " << double_area << std::endl;
assert(double_area == double_expected);
std::cout << "TEST PASSED" << std::endl << std::endl;
std::cout << "TEST PASSED!" << std::endl << std::endl;

// 10th test
double_radius = 4.0;
Expand All @@ -278,7 +278,7 @@ static void test() {
std::cout << "Expected Output: " << double_expected << std::endl;
std::cout << "Output: " << double_area << std::endl;
assert(double_area == double_expected);
std::cout << "TEST PASSED" << std::endl << std::endl;
std::cout << "TEST PASSED!" << std::endl << std::endl;

// 11th test
double_radius = 10.0;
Expand All @@ -290,7 +290,7 @@ static void test() {
std::cout << "Expected Output: " << double_expected << std::endl;
std::cout << "Output: " << double_area << std::endl;
assert(double_area == double_expected);
std::cout << "TEST PASSED" << std::endl << std::endl;
std::cout << "TEST PASSED!" << std::endl << std::endl;
}

/**
Expand Down
10 changes: 5 additions & 5 deletions math/check_factorial.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ namespace math {
* @return true if number is a factorial returns true
* @return false if number is not a factorial
*/
bool is_factorial(uint64_t n) {
if (n <= 0) { // factorial numbers are only ever positive Integers
bool is_factorial(uint64_t num) {
if (num <= 0) { // factorial numbers are only ever positive Integers
return false;
}

Expand All @@ -36,16 +36,16 @@ bool is_factorial(uint64_t n) {
* no impact division wise
*/
int i = 2;
while (n % i == 0) {
n = n / i;
while (num % i == 0) {
num = num / i;
i++;
}

/*!
* if n was the sum of a factorial then it should be divided until it
* becomes 1
*/
return (n == 1);
return (num == 1);
}
} // namespace math

Expand Down
Loading