package com.company; public class Main { public static void main(String[] args) { int n = 10; Integer[] arr = {102, 140, 172, 140, 293, 69, 36, 144, 82, 44, 205, 41, 30, 10 ,193, 348, 79, 176, 396, 145, 43, 193, 132, 2, 226, 170, 43, 127, 136, 165}; int s = 0; int ost; for (int i = 0; i<n; i++){ int ch = arr[i*3]*arr[i*3+1]+arr[i*3+2]; // число, сумму цифр которого надо посчитать. for (int a = 0; a<Integer.toString(ch).length(); a++){ ost = ch%10; ch /= 10; s += ost; } System.out.print(s+" "); s = 0; } } } The task is to find the sum of digits of a number, by dividing with the remainder. It seems a childish mistake, but I can not find