My issue
i am getting hidden case fail
My code
#include <stdio.h>
#include <math.h>
int is_armstrong(int number) {
int digits[10], n = 0, sum = 0, original_number = number;
// Extract digits and count them
while (number != 0) {
digits[n++] = number % 10;
number /= 10;
}
// Calculate the sum of n-th powers of digits
for (int i = 0; i < n; i++) {
sum += pow(digits[i], n);
}
// Check if the sum matches the original number
return sum == original_number;
}
int main() {
int N;
printf("Enter a number: ");
scanf("%d", &N);
if (is_armstrong(N)) {
printf("Armstrong\n");
} else {
printf("Not Armstrong\n");
}
return 0;
}
Learning course: Algorithmic Problem Solving
Problem Link: https://www.codechef.com/learn/course/klu-problem-solving/KLUPS00A/problems/LPYAS151