Armstrong number challenge - other testcase passed but first two testcases are not pasising kindly help

import java.util.*;
public class Main {
public static void main(String args[]) {
Scanner sc = new Scanner(System.in);
int N = sc.nextInt();
//function calling
System.out.println(Armstrong(N));
}

//function declaration	
public static boolean Armstrong(int N)
{
	int r = 0;
	int ans = 0;
	int temp = N;
	boolean isArmstrong = true;
	while(N!=0)
	{
		r = N%10;
		ans = ans + (r * r * r);
		N = N/10;
	}
	if(temp == ans)
	{
		return isArmstrong;
	}
	else
	{
		isArmstrong = false;
		return isArmstrong;
	}

}	

}

You need to count the digits of the no. first of all then try that power of that digit to every digit and sum that. And after that you need to check if that sum is equal to the no. itself.
As given in the explanation.
abcd… = pow(a,n) + pow(b,n) + pow(c,n) + pow(d,n) + ….

1634 is an Armstrong number as 1634 = 1^4 + 6^4 + 3^4 + 4^4

371 is an Armstrong number as 371 = 3^3 + 7^3 + 1^3

In 1634 we have taken the power 4 as the total digits of the nos. is 4.

I hope it is clear to you. In case it is clear to you pls mark it as resolve and provide the rating as well as feedback so that we can improve ourselves.
In case there is still some confusion pls let me know, I will surely try to help you out.
Thanks :slight_smile:
Happy Coding !!