0
Coding java
For a Range of 0 - 500 numbers, find all the numbers that satisfy both the below conditions 1)The number should have duplicate digits 2)The sum of the digits should be less than or equal to 5
2 Answers
+ 1
Attepmts?
to get sum of each digits of a number use this method
private static int getSumOfSquareOfEachDigits(int num) {
String number = String.valueOf(num);
int sum = 0;
for(int i = 0; i < number.length(); i++) {
int j = Character.digit(number.charAt(i), 10);
sum += j;
}
return sum;
}