mirror of
https://hub.njuu.cf/TheAlgorithms/C-Plus-Plus.git
synced 2023-10-11 13:05:55 +08:00
Showing 153 is not an Armstrong number. (#680)
* Update Armstrong Number.cpp * Update Armstrong Number.cpp * Update Armstrong Number.cpp * Update Armstrong Number.cpp * Rename Armstrong Number.cpp to armstrong_number.cpp * Update armstrong_number.cpp Showing 153 as not an Armstrong number. * Update armstrong_number.cpp
This commit is contained in:
parent
08451b1c4c
commit
f02bdb7390
@ -1,16 +1,17 @@
|
|||||||
//program to check whether a number is an armstrong number or not
|
// Program to check whether a number is an armstrong number or not
|
||||||
#include <iostream.h>
|
#include <iostream>
|
||||||
#include <Math.h>
|
|
||||||
int main()
|
using std::cout;
|
||||||
{
|
using std::cin;
|
||||||
|
|
||||||
|
int main() {
|
||||||
int n, k, d, s = 0;
|
int n, k, d, s = 0;
|
||||||
cout << "Enter a number:";
|
cout << "Enter a number:";
|
||||||
cin >> n;
|
cin >> n;
|
||||||
k = n;
|
k = n;
|
||||||
while (k != 0)
|
while (k != 0) {
|
||||||
{
|
|
||||||
d = k % 10;
|
d = k % 10;
|
||||||
s += (int)pow(d, 3);
|
s += d * d * d;
|
||||||
k /= 10;
|
k /= 10;
|
||||||
}
|
}
|
||||||
if (s == n)
|
if (s == n)
|
Loading…
Reference in New Issue
Block a user