+ |
+| namespace | math |
+| | for IO operations
|
+| |
+
|
-| uint64_t | phiFunction (uint64_t n) |
-| |
+| uint64_t | math::phiFunction (uint64_t n) |
+| | Function to calculate Euler's Totient.
|
+| |
+| static void | test () |
+| | Self-test implementations.
|
+| |
| int | main (int argc, char *argv[]) |
| | Main function.
|
| |
-
C++ Program to find Euler's Totient function.
-
Euler Totient Function is also known as phi function.
+
Implementation of Euler's Totient @description Euler Totient Function is also known as phi function.
+
\[\phi(n) =
\phi\left({p_1}^{a_1}\right)\cdot\phi\left({p_2}^{a_2}\right)\ldots\]
@@ -143,7 +154,8 @@ Some known values are:
- \(\phi(100) = 40\)
- \(\phi(1) = 1\)
- \(\phi(17501) = 15120\)
-- \(\phi(1420) = 560\)
+- \(\phi(1420) = 560\)
- Author
- Mann Mehta
+
@@ -173,62 +185,73 @@ Some known values are:
Main function.
-
48 {
-
49 uint64_t n;
-
50 if (argc < 2) {
-
-
52 } else {
-
-
54 }
-
-
-
57 return 0;
-
58}
-
-
-
uint64_t phiFunction(uint64_t n)
Definition: eulers_totient_function.cpp:32
-
+
- Parameters
-
+
+ | argc | commandline argument count (ignored) |
+ | argv | commandline array of arguments (ignored) |
+
+
+
+
- Returns
- 0 on exit
+
75 {
+
+
77 return 0;
+
78}
+
static void test()
Self-test implementations.
Definition: eulers_totient_function.cpp:57
-
-
◆ phiFunction()
+
+
◆ test()
+
+
+
- | uint64_t phiFunction |
+ static void test |
( |
- uint64_t |
- n | ) |
+ | ) |
|
+ |
+
+static |
+
+
-
Function to caculate Euler's totient phi
-
32 {
-
-
34 for (uint64_t i = 2; i * i <= n; i++) {
-
35 if (n % i == 0) {
-
36 while (n % i == 0) {
-
37 n /= i;
-
38 }
-
-
40 }
-
41 }
-
42 if (n > 1)
-
-
-
45}
-
uint64_t result(uint64_t n)
Definition: fibonacci_sum.cpp:76
-
+
+
Self-test implementations.
+
- Returns
- void
+
57 {
+
+
+
+
+
+
+
+
65
+
66 std::cout <<
"All tests have successfully passed!\n";
+
67}
+
+
uint64_t phiFunction(uint64_t n)
Function to calculate Euler's Totient.
Definition: eulers_totient_function.cpp:39
+
+
+
diff --git a/da/d23/eulers__totient__function_8cpp.js b/da/d23/eulers__totient__function_8cpp.js
index 6ae58b409..a0f943851 100644
--- a/da/d23/eulers__totient__function_8cpp.js
+++ b/da/d23/eulers__totient__function_8cpp.js
@@ -1,5 +1,6 @@
var eulers__totient__function_8cpp =
[
[ "main", "da/d23/eulers__totient__function_8cpp.html#a0ddf1224851353fc92bfbff6f499fa97", null ],
- [ "phiFunction", "da/d23/eulers__totient__function_8cpp.html#a35e4874a3e1d67eb708dc57944c8aea0", null ]
+ [ "phiFunction", "da/d23/eulers__totient__function_8cpp.html#ac37d3ba52eb296597d7a024ba8c4a5a5", null ],
+ [ "test", "da/d23/eulers__totient__function_8cpp.html#aa8dca7b867074164d5f45b0f3851269d", null ]
];
\ No newline at end of file
diff --git a/da/d23/eulers__totient__function_8cpp_a0ddf1224851353fc92bfbff6f499fa97_cgraph.map b/da/d23/eulers__totient__function_8cpp_a0ddf1224851353fc92bfbff6f499fa97_cgraph.map
index 77c8c7318..6da33bd44 100644
--- a/da/d23/eulers__totient__function_8cpp_a0ddf1224851353fc92bfbff6f499fa97_cgraph.map
+++ b/da/d23/eulers__totient__function_8cpp_a0ddf1224851353fc92bfbff6f499fa97_cgraph.map
@@ -1,4 +1,5 @@
diff --git a/da/d23/eulers__totient__function_8cpp_a0ddf1224851353fc92bfbff6f499fa97_cgraph.md5 b/da/d23/eulers__totient__function_8cpp_a0ddf1224851353fc92bfbff6f499fa97_cgraph.md5
index a6153b18e..0b59ec236 100644
--- a/da/d23/eulers__totient__function_8cpp_a0ddf1224851353fc92bfbff6f499fa97_cgraph.md5
+++ b/da/d23/eulers__totient__function_8cpp_a0ddf1224851353fc92bfbff6f499fa97_cgraph.md5
@@ -1 +1 @@
-fae26a9118bc9b5ec9435a78817b9af3
\ No newline at end of file
+c81d7ca75c445b958b4df7a25871ae61
\ No newline at end of file
diff --git a/da/d23/eulers__totient__function_8cpp_a0ddf1224851353fc92bfbff6f499fa97_cgraph.svg b/da/d23/eulers__totient__function_8cpp_a0ddf1224851353fc92bfbff6f499fa97_cgraph.svg
index 5358e120c..3daa15fd7 100644
--- a/da/d23/eulers__totient__function_8cpp_a0ddf1224851353fc92bfbff6f499fa97_cgraph.svg
+++ b/da/d23/eulers__totient__function_8cpp_a0ddf1224851353fc92bfbff6f499fa97_cgraph.svg
@@ -4,8 +4,8 @@
-