1
1
/* *
2
- * @file
3
- * @brief Program to check if a number is an [Armstrong/Narcissistic
4
- * number](https://en.wikipedia.org/wiki/Narcissistic_number) in decimal system.
5
- *
6
- * @details
7
- * Armstrong number or [Narcissistic
8
- * number](https://en.wikipedia.org/wiki/Narcissistic_number) is a number that
9
- * is the sum of its own digits raised to the power of the number of digits.
10
- *
11
- * let n be the narcissistic number,
12
- * \f[F_b(n) = \sum_{i=0}^{k-1}d_{i}^{k}\f] for
13
- * \f$ b > 1 F_b : \N \to \N \f$ where
14
- * \f$ k = \lfloor log_b n\rfloor is the number of digits in the number in base \f$b\f$, and
15
- * \f$ d_i = \frac{n mod b^{i+1} - n mod b^{i}}{b^{i}} \f$
16
- *
17
- * @author [Neeraj Cherkara](https://github.com/iamnambiar)
18
- */
19
- #include < cassert> // / for assert
20
- #include < cmath> // / for std::pow
21
- #include < iostream> // / for IO operations
2
+ * @file
3
+ * @brief Program to check if a number is an [Armstrong/Narcissistic
4
+ * number](https://en.wikipedia.org/wiki/Narcissistic_number) in decimal system.
5
+ *
6
+ * @details
7
+ * Armstrong number or [Narcissistic
8
+ * number](https://en.wikipedia.org/wiki/Narcissistic_number) is a number that
9
+ * is the sum of its own digits raised to the power of the number of digits.
10
+ *
11
+ * let n be the narcissistic number,
12
+ * \f[F_b(n) = \sum_{i=0}^{k-1}d_{i}^{k}\f] for
13
+ * \f$ b > 1 F_b : \N \to \N \f$ where
14
+ * \f$ k = \lfloor log_b n\rfloor is the number of digits in the number in base
15
+ * \f$b\f$, and \f$ d_i = \frac{n mod b^{i+1} - n mod b^{i}}{b^{i}} \f$
16
+ *
17
+ * @author [Neeraj Cherkara](https://github.com/iamnambiar)
18
+ */
19
+ #include < cassert> // / for assert
20
+ #include < cmath> // / for std::pow
21
+ #include < iostream> // / for IO operations
22
22
23
23
/* *
24
24
* @brief Function to calculate the total number of digits in the number.
@@ -61,9 +61,9 @@ bool is_armstrong(int number) {
61
61
}
62
62
63
63
/* *
64
- * @brief Self-test implementations
65
- * @returns void
66
- */
64
+ * @brief Self-test implementations
65
+ * @returns void
66
+ */
67
67
static void test () {
68
68
// is_armstrong(370) returns true.
69
69
assert (is_armstrong (370 ) == true );
@@ -82,10 +82,10 @@ static void test() {
82
82
}
83
83
84
84
/* *
85
- * @brief Main Function
86
- * @returns 0 on exit
87
- */
85
+ * @brief Main Function
86
+ * @returns 0 on exit
87
+ */
88
88
int main () {
89
- test (); // run self-test implementations
89
+ test (); // run self-test implementations
90
90
return 0 ;
91
91
}
0 commit comments