From 24cf24b55785a7f491e871a3a9f38cefed810875 Mon Sep 17 00:00:00 2001 From: github-actions <${GITHUB_ACTOR}@users.noreply.github.com> Date: Fri, 28 Apr 2023 20:03:18 +0000 Subject: [PATCH] Documentation for 4b740d464c8e8898162181b615efe7884d1980be --- da/d23/eulers__totient__function_8cpp.html | 117 +++++++++++------- da/d23/eulers__totient__function_8cpp.js | 3 +- ...ddf1224851353fc92bfbff6f499fa97_cgraph.map | 3 +- ...ddf1224851353fc92bfbff6f499fa97_cgraph.md5 | 2 +- ...ddf1224851353fc92bfbff6f499fa97_cgraph.svg | 29 +++-- ...8dca7b867074164d5f45b0f3851269d_cgraph.map | 4 + ...8dca7b867074164d5f45b0f3851269d_cgraph.md5 | 1 + ...8dca7b867074164d5f45b0f3851269d_cgraph.svg | 36 ++++++ dd/d47/namespacemath.html | 41 ++++++ dd/d47/namespacemath.js | 1 + .../eulers__totient__function_8cpp__incl.map | 6 +- .../eulers__totient__function_8cpp__incl.md5 | 2 +- .../eulers__totient__function_8cpp__incl.svg | 28 ++--- dir_296d53ceaeaa7e099814a6def439fe8a.html | 2 +- files.html | 2 +- globals_func_p.html | 1 - globals_func_t.html | 2 +- globals_p.html | 1 - globals_t.html | 2 +- namespacemembers.html | 1 + namespacemembers_func.html | 1 + navtreedata.js | 8 +- navtreeindex0.js | 22 ++-- navtreeindex1.js | 14 +-- navtreeindex10.js | 6 +- navtreeindex11.js | 62 +++++----- navtreeindex12.js | 20 +-- navtreeindex13.js | 10 +- navtreeindex2.js | 12 +- navtreeindex3.js | 4 +- navtreeindex4.js | 4 +- navtreeindex5.js | 10 +- navtreeindex6.js | 30 ++--- navtreeindex7.js | 28 ++--- navtreeindex8.js | 20 +-- navtreeindex9.js | 16 +-- search/all_11.js | 2 +- search/all_15.js | 6 +- search/functions_10.js | 2 +- search/functions_14.js | 2 +- 40 files changed, 344 insertions(+), 219 deletions(-) create mode 100644 da/d23/eulers__totient__function_8cpp_aa8dca7b867074164d5f45b0f3851269d_cgraph.map create mode 100644 da/d23/eulers__totient__function_8cpp_aa8dca7b867074164d5f45b0f3851269d_cgraph.md5 create mode 100644 da/d23/eulers__totient__function_8cpp_aa8dca7b867074164d5f45b0f3851269d_cgraph.svg diff --git a/da/d23/eulers__totient__function_8cpp.html b/da/d23/eulers__totient__function_8cpp.html index 83355afff..2e7ecdb89 100644 --- a/da/d23/eulers__totient__function_8cpp.html +++ b/da/d23/eulers__totient__function_8cpp.html @@ -98,33 +98,44 @@ $(document).ready(function(){initNavTree('da/d23/eulers__totient__function_8cpp.
+Namespaces | Functions
eulers_totient_function.cpp File Reference
-

C++ Program to find Euler's Totient function. +

Implementation of Euler's Totient @description Euler Totient Function is also known as phi function. More...

-
#include <cstdlib>
-#include <iostream>
+
#include <iostream>
+#include <cassert>
Include dependency graph for eulers_totient_function.cpp:
-
+
+ + + + +

+Namespaces

namespace  math
 for IO operations
 
- - + + + + + +

Functions

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.
 

Detailed Description

-

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
    +

Function Documentation

@@ -173,62 +185,73 @@ Some known values are:

Main function.

-
48 {
-
49 uint64_t n;
-
50 if (argc < 2) {
-
51 std::cout << "Enter the number: ";
-
52 } else {
-
53 n = strtoull(argv[1], nullptr, 10);
-
54 }
-
55 std::cin >> n;
- -
57 return 0;
-
58}
- - -
uint64_t phiFunction(uint64_t n)
Definition: eulers_totient_function.cpp:32
-
T strtoull(T... args)
+
Parameters
+ + + +
argccommandline argument count (ignored)
argvcommandline array of arguments (ignored)
+
+
+
Returns
0 on exit
+
75 {
+
76 test();
+
77 return 0;
+
78}
+
static void test()
Self-test implementations.
Definition: eulers_totient_function.cpp:57
Here is the call graph for this function:
-
+
- -

◆ phiFunction()

+ +

◆ test()

+ + + + + +
- + - - +
uint64_t phiFunction static void test (uint64_t n))
+
+static
-

Function to caculate Euler's totient phi

-
32 {
-
33 uint64_t result = n;
-
34 for (uint64_t i = 2; i * i <= n; i++) {
-
35 if (n % i == 0) {
-
36 while (n % i == 0) {
-
37 n /= i;
-
38 }
-
39 result -= result / i;
-
40 }
-
41 }
-
42 if (n > 1)
-
43 result -= result / n;
-
44 return result;
-
45}
-
uint64_t result(uint64_t n)
Definition: fibonacci_sum.cpp:76
-
+ +

Self-test implementations.

+
Returns
void
+
57 {
+
58 assert(math::phiFunction(1) == 1);
+
59 assert(math::phiFunction(2) == 1);
+
60 assert(math::phiFunction(10) == 4);
+
61 assert(math::phiFunction(123456) == 41088);
+
62 assert(math::phiFunction(808017424794) == 263582333856);
+
63 assert(math::phiFunction(3141592) == 1570792);
+
64 assert(math::phiFunction(27182818) == 12545904);
+
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
+
+Here is the call graph for this function:
+
+
+
+
+
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 @@ - + main @@ -20,17 +20,32 @@ Node2 - - -phiFunction + + +test Node1->Node2 - - + + + + + +Node3 + + +math::phiFunction + + + + + +Node2->Node3 + + diff --git a/da/d23/eulers__totient__function_8cpp_aa8dca7b867074164d5f45b0f3851269d_cgraph.map b/da/d23/eulers__totient__function_8cpp_aa8dca7b867074164d5f45b0f3851269d_cgraph.map new file mode 100644 index 000000000..c31afa1ee --- /dev/null +++ b/da/d23/eulers__totient__function_8cpp_aa8dca7b867074164d5f45b0f3851269d_cgraph.map @@ -0,0 +1,4 @@ + + + + diff --git a/da/d23/eulers__totient__function_8cpp_aa8dca7b867074164d5f45b0f3851269d_cgraph.md5 b/da/d23/eulers__totient__function_8cpp_aa8dca7b867074164d5f45b0f3851269d_cgraph.md5 new file mode 100644 index 000000000..2c3533f61 --- /dev/null +++ b/da/d23/eulers__totient__function_8cpp_aa8dca7b867074164d5f45b0f3851269d_cgraph.md5 @@ -0,0 +1 @@ +902e525783a53dd6ff16a1209bee2875 \ No newline at end of file diff --git a/da/d23/eulers__totient__function_8cpp_aa8dca7b867074164d5f45b0f3851269d_cgraph.svg b/da/d23/eulers__totient__function_8cpp_aa8dca7b867074164d5f45b0f3851269d_cgraph.svg new file mode 100644 index 000000000..dc078cbde --- /dev/null +++ b/da/d23/eulers__totient__function_8cpp_aa8dca7b867074164d5f45b0f3851269d_cgraph.svg @@ -0,0 +1,36 @@ + + + + + + +test + + +Node1 + + +test + + + + + +Node2 + + +math::phiFunction + + + + + +Node1->Node2 + + + + + diff --git a/dd/d47/namespacemath.html b/dd/d47/namespacemath.html index aa8b47b92..9ea8ebd60 100644 --- a/dd/d47/namespacemath.html +++ b/dd/d47/namespacemath.html @@ -156,6 +156,9 @@ Functions
void print_primes (std::vector< bool > const &primes)
 Prints all the indexes of true values in the passed std::vector.

  +uint64_t phiFunction (uint64_t n) + Function to calculate Euler's Totient.
+  double integral_approx (double lb, double ub, const std::function< double(double)> &func, double delta=.0001)  Computes integral approximation.
  @@ -1167,6 +1170,44 @@ template<typename T >
+ +

◆ phiFunction()

+ +
+
+ + + + + + + + +
uint64_t math::phiFunction (uint64_t n)
+
+ +

Function to calculate Euler's Totient.

+
Parameters
+ + +
nthe number to find the Euler's Totient of
+
+
+
39 {
+
40 uint64_t result = n;
+
41 for (uint64_t i = 2; i * i <= n; i++) {
+
42 if (n % i != 0) continue;
+
43 while (n % i == 0) n /= i;
+
44
+
45 result -= result / i;
+
46 }
+
47 if (n > 1) result -= result / n;
+
48
+
49 return result;
+
50}
+
+
+

◆ power()

diff --git a/dd/d47/namespacemath.js b/dd/d47/namespacemath.js index a6ec41bdb..188622d31 100644 --- a/dd/d47/namespacemath.js +++ b/dd/d47/namespacemath.js @@ -21,6 +21,7 @@ var namespacemath = [ "n_polygon_surface_perimeter", "dd/d47/namespacemath.html#aa8592c3279c41a2c6d4d64eeb488f63f", null ], [ "parallelogram_area", "dd/d47/namespacemath.html#a5de184925e68658f15415dd53954df4f", null ], [ "parallelogram_perimeter", "dd/d47/namespacemath.html#a0efb235330ff48e14fd31faaccbcebb3", null ], + [ "phiFunction", "dd/d47/namespacemath.html#ac37d3ba52eb296597d7a024ba8c4a5a5", null ], [ "power", "dd/d47/namespacemath.html#afcd07701d73ed65cd616bcba02737f3d", null ], [ "power_of_two", "dd/d47/namespacemath.html#a8a48be4d7f14e34c5c92925bc1cbf3bb", null ], [ "print_primes", "dd/d47/namespacemath.html#ad09d59850865012a6fd95d89954c82e4", null ], diff --git a/de/d5b/eulers__totient__function_8cpp__incl.map b/de/d5b/eulers__totient__function_8cpp__incl.map index 2648e5a67..f8798bfb9 100644 --- a/de/d5b/eulers__totient__function_8cpp__incl.map +++ b/de/d5b/eulers__totient__function_8cpp__incl.map @@ -1,5 +1,5 @@ - - - + + + diff --git a/de/d5b/eulers__totient__function_8cpp__incl.md5 b/de/d5b/eulers__totient__function_8cpp__incl.md5 index 1e2470836..4ef0f4747 100644 --- a/de/d5b/eulers__totient__function_8cpp__incl.md5 +++ b/de/d5b/eulers__totient__function_8cpp__incl.md5 @@ -1 +1 @@ -8e294dbb30a320591f0a831ceaf70d6a \ No newline at end of file +e82a1c4dfe5dd8f00664d269187f4525 \ No newline at end of file diff --git a/de/d5b/eulers__totient__function_8cpp__incl.svg b/de/d5b/eulers__totient__function_8cpp__incl.svg index da3aa7dc9..94974661d 100644 --- a/de/d5b/eulers__totient__function_8cpp__incl.svg +++ b/de/d5b/eulers__totient__function_8cpp__incl.svg @@ -4,17 +4,17 @@ - + math/eulers_totient_function.cpp Node1 - - -math/eulers_totient -_function.cpp + + +math/eulers_totient +_function.cpp @@ -22,31 +22,31 @@ Node2 - -cstdlib + +iostream Node1->Node2 - - + + Node3 - -iostream + +cassert Node1->Node3 - - + + diff --git a/dir_296d53ceaeaa7e099814a6def439fe8a.html b/dir_296d53ceaeaa7e099814a6def439fe8a.html index ef2124f1b..983ed4573 100644 --- a/dir_296d53ceaeaa7e099814a6def439fe8a.html +++ b/dir_296d53ceaeaa7e099814a6def439fe8a.html @@ -140,7 +140,7 @@ Files
 The Sieve of Eratosthenes

  file  eulers_totient_function.cpp - C++ Program to find Euler's Totient function.
+ Implementation of Euler's Totient @description Euler Totient Function is also known as phi function.
  file  extended_euclid_algorithm.cpp  GCD using [extended Euclid's algorithm] (https://en.wikipedia.org/wiki/Extended_Euclidean_algorithm)
diff --git a/files.html b/files.html index a2279e4c5..0956f5440 100644 --- a/files.html +++ b/files.html @@ -231,7 +231,7 @@ solve-a-rat-in-a-maze-c-java-pytho/" target="_blank">Rat in a Maze algorithm  complex_numbers.cppAn implementation of Complex Number as Objects  double_factorial.cppCompute double factorial: \(n!!\)  eratosthenes.cppThe Sieve of Eratosthenes - eulers_totient_function.cppC++ Program to find Euler's Totient function + eulers_totient_function.cppImplementation of Euler's Totient @description Euler Totient Function is also known as phi function  extended_euclid_algorithm.cppGCD using [extended Euclid's algorithm] (https://en.wikipedia.org/wiki/Extended_Euclidean_algorithm)  factorial.cppC++ program to find factorial of given number  fast_power.cppFaster computation for \(a^b\) diff --git a/globals_func_p.html b/globals_func_p.html index 699eed79e..e5d8a1917 100644 --- a/globals_func_p.html +++ b/globals_func_p.html @@ -101,7 +101,6 @@ $(document).ready(function(){initNavTree('globals_func_p.html',''); initResizabl

- p -