//I have made own code for your project, it was easier to make notes on my work. All you can see in my code are in your as well, you can compare them. Good luck. :)
//For C language
#include <stdio.h>
int main()
{
int number=1000; //this is the smallest 4 digit number
int thousands; //declarate our variables [ X _ _ _ ]
int hundreds; //declarate our variables [ _ X _ _ ]
int decimals; //declarate our variables [ _ _ X _ ]
int firstdigit; //declarate our variables [ _ _ _ X ] (First digit is the lowest number)
int sum3digit; //declarate our variables (we should summarise the 3 digits except first digit)
while(number<10000) //start a loop to go throught numbers from the declared 1000 to 9999 (not number<=10000, so it is not examined)
{
thousands=number/1000; //find out the last digit [ X _ _ _ ] (it is INTIGER so for example 8542 devided by 1000 is 8 and not 8,542)
hundreds=(number%1000)/100; //find out this digit [ _ X _ _ ] (using modulo, for example 8542 modulo 1000 is 542 because 8542/1000 and we get the rest 542; 542/100=5 like above)
decimals=(number%100)/10; //find out this digit [ _ _ X _ ] (using modulo, for example 8542 modulo 100 is 42 because 8542/100 and we get the rest 42; 42/10=4 like above)
firstdigit=(number%10); //find out firstdigit [ _ _ _ X ] (using modulo, for example 8542 modulo 10 is 2 because 8542/10 and we get the rest 2)
sum3digit=thousands+hundreds+decimals; //here we summarise the 3 digits except first digit
if(firstdigit==sum3digit) //make a criterion, check if the firstdigit and other 3 digits summ are the same? IF YES step into { }, IF NO jump over { }
{
printf("%d\n",number); //print the number to the terminal/output/screen when run the program ( "%d" means decimal/intiger "\n" means cursor go to next line )
}
number++; //here we increment number to go throught 1000 to 9999 (one by one, so 1000 1001 1002 1003 etc 9997 9998 9999)
}
return 0; //have to use at the end of the source code, inside the [ main() { } ]
}