0
My code receives as input the value of n
, i
and j
and calculates the n
first multiples of i
and j
. I’ve gone through my loop loop and I can’t find anything wrong, but the compiler just stands still and doesn’t report the values.
int i, j, n, k;
printf("Digite o valor de n : ");
scanf("%d",&n);
printf("Digite o valor de i : ");
scanf("%d",&i);
printf("Digite o valor de j : ");
scanf("%d",&j);
k = 0;
printf("Os %d primeiros multiplos de %d e %d sao : ",n,i,j);
while (k < n){
if (k % i == 0 || k % j == 0 || (k % i == 0 && k % j == 0){
printf("%d \t",k);
k++;
}
}
Thanks friend, I had done with a loop for earlier but had only used a single variable that was k, so it n ran correctly, then I ended up going for while. I hadn’t thought about the possibility of two variables.
– Matheus Santos