diff --git a/d0/da2/number__of__positive__divisors_8cpp.html b/d0/da2/number__of__positive__divisors_8cpp.html index a5799c7de..af8214652 100644 --- a/d0/da2/number__of__positive__divisors_8cpp.html +++ b/d0/da2/number__of__positive__divisors_8cpp.html @@ -120,7 +120,6 @@ $(function(){initNavTree('d0/da2/number__of__positive__divisors_8cpp.html','../.

C++ Program to calculate the number of positive divisors. More...

#include <cassert>
-#include <iostream>
Include dependency graph for number_of_positive_divisors.cpp:
@@ -165,21 +164,12 @@ list of positive divisors of 36 = 1, 2, 3, 4, 6, 9, 12, 18, 36.

Main function

-

Definition at line 81 of file number_of_positive_divisors.cpp.

-
81 {
-
82 tests();
-
83 int n;
-
84 std::cin >> n;
-
85 if (n == 0) {
-
86 std::cout << "All non-zero numbers are divisors of 0 !" << std::endl;
-
87 } else {
-
88 std::cout << "Number of positive divisors is : ";
-
89 std::cout << number_of_positive_divisors(n) << std::endl;
-
90 }
-
91 return 0;
-
92}
- -
int number_of_positive_divisors(int n)
+

Definition at line 80 of file number_of_positive_divisors.cpp.

+
80 {
+
81 tests();
+
82 return 0;
+
83}
+
@@ -205,40 +195,40 @@ list of positive divisors of 36 = 1, 2, 3, 4, 6, 9, 12, 18, 36.

Returns
number of positive divisors of n (or 1 if n = 0)
-

Definition at line 33 of file number_of_positive_divisors.cpp.

-
33 {
-
34 if (n < 0) {
-
35 n = -n; // take the absolute value of n
-
36 }
-
37
-
38 int number_of_divisors = 1;
-
39
-
40 for (int i = 2; i * i <= n; i++) {
-
41 // This part is doing the prime factorization.
-
42 // Note that we cannot find a composite divisor of n unless we would
-
43 // already previously find the corresponding prime divisor and dvided
-
44 // n by that prime. Therefore, all the divisors found here will
-
45 // actually be primes.
-
46 // The loop terminates early when it is left with a number n which
-
47 // does not have a divisor smaller or equal to sqrt(n) - that means
-
48 // the remaining number is a prime itself.
-
49 int prime_exponent = 0;
-
50 while (n % i == 0) {
-
51 // Repeatedly divide n by the prime divisor n to compute
-
52 // the exponent (e_i in the algorithm description).
-
53 prime_exponent++;
-
54 n /= i;
-
55 }
-
56 number_of_divisors *= prime_exponent + 1;
-
57 }
-
58 if (n > 1) {
-
59 // In case the remaining number n is a prime number itself
-
60 // (essentially p_k^1) the final answer is also multiplied by (e_k+1).
-
61 number_of_divisors *= 2;
-
62 }
-
63
-
64 return number_of_divisors;
-
65}
+

Definition at line 32 of file number_of_positive_divisors.cpp.

+
32 {
+
33 if (n < 0) {
+
34 n = -n; // take the absolute value of n
+
35 }
+
36
+
37 int number_of_divisors = 1;
+
38
+
39 for (int i = 2; i * i <= n; i++) {
+
40 // This part is doing the prime factorization.
+
41 // Note that we cannot find a composite divisor of n unless we would
+
42 // already previously find the corresponding prime divisor and dvided
+
43 // n by that prime. Therefore, all the divisors found here will
+
44 // actually be primes.
+
45 // The loop terminates early when it is left with a number n which
+
46 // does not have a divisor smaller or equal to sqrt(n) - that means
+
47 // the remaining number is a prime itself.
+
48 int prime_exponent = 0;
+
49 while (n % i == 0) {
+
50 // Repeatedly divide n by the prime divisor n to compute
+
51 // the exponent (e_i in the algorithm description).
+
52 prime_exponent++;
+
53 n /= i;
+
54 }
+
55 number_of_divisors *= prime_exponent + 1;
+
56 }
+
57 if (n > 1) {
+
58 // In case the remaining number n is a prime number itself
+
59 // (essentially p_k^1) the final answer is also multiplied by (e_k+1).
+
60 number_of_divisors *= 2;
+
61 }
+
62
+
63 return number_of_divisors;
+
64}
@@ -258,14 +248,15 @@ list of positive divisors of 36 = 1, 2, 3, 4, 6, 9, 12, 18, 36.

Test implementations

-

Definition at line 70 of file number_of_positive_divisors.cpp.

-
70 {
-
71 assert(number_of_positive_divisors(36) == 9);
-
72 assert(number_of_positive_divisors(-36) == 9);
-
73 assert(number_of_positive_divisors(1) == 1);
-
74 assert(number_of_positive_divisors(2011) == 2); // 2011 is a prime
-
75 assert(number_of_positive_divisors(756) == 24); // 756 = 2^2 * 3^3 * 7
-
76}
+

Definition at line 69 of file number_of_positive_divisors.cpp.

+
69 {
+
70 assert(number_of_positive_divisors(36) == 9);
+
71 assert(number_of_positive_divisors(-36) == 9);
+
72 assert(number_of_positive_divisors(1) == 1);
+
73 assert(number_of_positive_divisors(2011) == 2); // 2011 is a prime
+
74 assert(number_of_positive_divisors(756) == 24); // 756 = 2^2 * 3^3 * 7
+
75}
+
int number_of_positive_divisors(int n)
diff --git a/d0/da2/number__of__positive__divisors_8cpp_source.html b/d0/da2/number__of__positive__divisors_8cpp_source.html index 8c7f45145..3a537cc24 100644 --- a/d0/da2/number__of__positive__divisors_8cpp_source.html +++ b/d0/da2/number__of__positive__divisors_8cpp_source.html @@ -119,71 +119,62 @@ $(function(){initNavTree('d0/da2/number__of__positive__divisors_8cpp_source.html Go to the documentation of this file.
1
24
25#include <cassert>
-
26#include <iostream>
-
27
-
- -
34 if (n < 0) {
-
35 n = -n; // take the absolute value of n
-
36 }
-
37
-
38 int number_of_divisors = 1;
-
39
-
40 for (int i = 2; i * i <= n; i++) {
-
41 // This part is doing the prime factorization.
-
42 // Note that we cannot find a composite divisor of n unless we would
-
43 // already previously find the corresponding prime divisor and dvided
-
44 // n by that prime. Therefore, all the divisors found here will
-
45 // actually be primes.
-
46 // The loop terminates early when it is left with a number n which
-
47 // does not have a divisor smaller or equal to sqrt(n) - that means
-
48 // the remaining number is a prime itself.
-
49 int prime_exponent = 0;
-
50 while (n % i == 0) {
-
51 // Repeatedly divide n by the prime divisor n to compute
-
52 // the exponent (e_i in the algorithm description).
-
53 prime_exponent++;
-
54 n /= i;
-
55 }
-
56 number_of_divisors *= prime_exponent + 1;
-
57 }
-
58 if (n > 1) {
-
59 // In case the remaining number n is a prime number itself
-
60 // (essentially p_k^1) the final answer is also multiplied by (e_k+1).
-
61 number_of_divisors *= 2;
-
62 }
-
63
-
64 return number_of_divisors;
-
65}
+
26
+
+ +
33 if (n < 0) {
+
34 n = -n; // take the absolute value of n
+
35 }
+
36
+
37 int number_of_divisors = 1;
+
38
+
39 for (int i = 2; i * i <= n; i++) {
+
40 // This part is doing the prime factorization.
+
41 // Note that we cannot find a composite divisor of n unless we would
+
42 // already previously find the corresponding prime divisor and dvided
+
43 // n by that prime. Therefore, all the divisors found here will
+
44 // actually be primes.
+
45 // The loop terminates early when it is left with a number n which
+
46 // does not have a divisor smaller or equal to sqrt(n) - that means
+
47 // the remaining number is a prime itself.
+
48 int prime_exponent = 0;
+
49 while (n % i == 0) {
+
50 // Repeatedly divide n by the prime divisor n to compute
+
51 // the exponent (e_i in the algorithm description).
+
52 prime_exponent++;
+
53 n /= i;
+
54 }
+
55 number_of_divisors *= prime_exponent + 1;
+
56 }
+
57 if (n > 1) {
+
58 // In case the remaining number n is a prime number itself
+
59 // (essentially p_k^1) the final answer is also multiplied by (e_k+1).
+
60 number_of_divisors *= 2;
+
61 }
+
62
+
63 return number_of_divisors;
+
64}
-
66
-
-
70void tests() {
-
71 assert(number_of_positive_divisors(36) == 9);
-
72 assert(number_of_positive_divisors(-36) == 9);
-
73 assert(number_of_positive_divisors(1) == 1);
-
74 assert(number_of_positive_divisors(2011) == 2); // 2011 is a prime
-
75 assert(number_of_positive_divisors(756) == 24); // 756 = 2^2 * 3^3 * 7
-
76}
+
65
+
+
69void tests() {
+
70 assert(number_of_positive_divisors(36) == 9);
+
71 assert(number_of_positive_divisors(-36) == 9);
+
72 assert(number_of_positive_divisors(1) == 1);
+
73 assert(number_of_positive_divisors(2011) == 2); // 2011 is a prime
+
74 assert(number_of_positive_divisors(756) == 24); // 756 = 2^2 * 3^3 * 7
+
75}
-
77
-
-
81int main() {
-
82 tests();
-
83 int n;
-
84 std::cin >> n;
-
85 if (n == 0) {
-
86 std::cout << "All non-zero numbers are divisors of 0 !" << std::endl;
-
87 } else {
-
88 std::cout << "Number of positive divisors is : ";
-
89 std::cout << number_of_positive_divisors(n) << std::endl;
-
90 }
-
91 return 0;
-
92}
+
76
+
+
80int main() {
+
81 tests();
+
82 return 0;
+
83}
- -
int number_of_positive_divisors(int n)
- + +
int number_of_positive_divisors(int n)
+
diff --git a/d4/da4/number__of__positive__divisors_8cpp__incl.map b/d4/da4/number__of__positive__divisors_8cpp__incl.map index 12e896ff8..152cedc5e 100644 --- a/d4/da4/number__of__positive__divisors_8cpp__incl.map +++ b/d4/da4/number__of__positive__divisors_8cpp__incl.map @@ -1,7 +1,5 @@ - - - - + + diff --git a/d4/da4/number__of__positive__divisors_8cpp__incl.md5 b/d4/da4/number__of__positive__divisors_8cpp__incl.md5 index 97fc1857d..7ee15c30d 100644 --- a/d4/da4/number__of__positive__divisors_8cpp__incl.md5 +++ b/d4/da4/number__of__positive__divisors_8cpp__incl.md5 @@ -1 +1 @@ -ee602381f16f2167c8958b8171981736 \ No newline at end of file +a4dfe7f93eadf8d5b49ba26221536250 \ No newline at end of file diff --git a/d4/da4/number__of__positive__divisors_8cpp__incl.svg b/d4/da4/number__of__positive__divisors_8cpp__incl.svg index 52161b0a5..c8da33aa9 100644 --- a/d4/da4/number__of__positive__divisors_8cpp__incl.svg +++ b/d4/da4/number__of__positive__divisors_8cpp__incl.svg @@ -33,8 +33,8 @@ Node2 - -cassert + +cassert @@ -42,26 +42,8 @@ Node1->Node2 - - - - - - - -Node3 - - -iostream - - - - - -Node1->Node3 - - - + + diff --git a/d4/da4/number__of__positive__divisors_8cpp__incl_org.svg b/d4/da4/number__of__positive__divisors_8cpp__incl_org.svg index 5a276681e..b00a6824e 100644 --- a/d4/da4/number__of__positive__divisors_8cpp__incl_org.svg +++ b/d4/da4/number__of__positive__divisors_8cpp__incl_org.svg @@ -22,8 +22,8 @@ Node2 - -cassert + +cassert @@ -31,26 +31,8 @@ Node1->Node2 - - - - - - - -Node3 - - -iostream - - - - - -Node1->Node3 - - - + +