Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- int calculateQubes(int n) {
- return (n * n * n);
- }
- int isArmstrong(int n) {
- int temp = n;
- int sum = 0;
- while (temp > 0) {
- int x = temp % 10;
- sum += calculateQubes(x);
- temp /= 10;
- }
- // printf("Sum = %d\n", sum);
- return sum;
- }
- int main() {
- for (int i = 1; i <= 500; i++) {
- if (isArmstrong(i) == i) {
- printf("%d\n", i);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement