I have been working on a program to take integer x and find any numbers whose sum of the digits multiplied by x equals the number. my code has worked for numbers 2, 3, and 4, but beyond that is returns various errors regardless of what i am doing. any help would be greatly appreciated.
my code:
package SumOfTheDigits;
public class Test
{
public static void main(String[] args) throws java.lang.Exception
{
int a = 3;
int x = 1;
int solutions = (9 - ((((10 * x) - (a * x))/(a - 1)) % 9))/(((10 * x) -
(a * x))/(a - 1));
for(int z = 1; z < solutions + 2; z++)
{
if((z * 10) + ((10 * z) - (a * z))/(a - 1) == a * (z + ((10 * z) -
(a * z))/(a - 1)))
{
System.out.println(z + "" + ((10 * z) - (a * z))/(a - 1));
}
}
}
}