Error in code getting false only

import java.util.*;

public class ques4938_1102_armstrong {

public static void main(String[] args) {
	// TODO Auto-generated method stub
	Scanner sc = new Scanner(System.in);
	int n = sc.nextInt();
	if(n>0 && n< 1000000000) {
	int a= check(n);
	if(n == a) {
		 System.out.println("true");
	}else {
		System.out.println("false");
	}	
	}
	else {
		System.out.println("n out of range");
	}
	
}
public static int check(int a) {
	
	int rem;
	int sum =0;
	int nod =0;
	int count =0;
	while(a>0) {
		 
		a = a/10;
		count++;
		
		}
	for (int i =1;i<=count; i++) {
		rem = a%10;
		sum = (int )(sum + Math.pow(rem, count));
		a=a/10;
				
	}
	return sum;
}

}