#include <stdio.h>
#include <stdlib.h>
int main() {
int n, i;
printf("n: ");
scanf("%d", &n);
for (i = 100; i <= 999; i++) {
int x = i / 100;
int y = i / 10 % 10;
int z = i % 10;
int suma = x * x + y * y - z * z;
if (n % suma == 0)
printf("%d %d %d %d\n", i, x, y, z);
}
return 0;
}
This code is supposed to check if a 3 digit number(xyz) follows this property:
n % (x2 + y2 - z2) == 0.
For some reason, when I run this code, it just crashes, without any errors or warnings. I'm new to programming, and I would like some help.
I tried changing the if
statement, but it doesn't change anything. What am I missing?