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

2nd Jan 2023, 3:24 PM
4071 - Ragul Prasanth S
4071 - Ragul Prasanth S - avatar
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; }
2nd Jan 2023, 3:34 PM
AÍąJ
AÍąJ - avatar