1. ## check every condition

i made one loop which has another loop inside it like this:
Code:
```	for(y=1;y<11;y+=1){
for(x=0;x<5000;x+=1){
if (x % y==0){
printf("%d \n",x);}}}```
when i run it tries the if condition indiviually b ut i am trying make it try for every "y"
how can i do it?

2. Originally Posted by alperen1994
when i run it tries the if condition indiviually b ut i am trying make it try for every "y"
As in you want to print all non-negative integers less than 5000 that are perfectly divisible by all the positive integers less than 11?

3. Originally Posted by alperen1994
i am trying make it try for every "y"
how can i do it?
It is. Maybe you wanted this in the printf to make that clearer:
Code:
`printf("x=%d y=%d\n",x,y);`

4. Originally Posted by laserlight
As in you want to print all non-negative integers less than 5000 that are perfectly divisible by all the positive integers less than 11?
i want the all numbers between 0-50000 that can divided with all numbers between 0-11

5. Originally Posted by alperen1994
i want the all numbers between 0-50000 that can divided with all numbers between 0-11
so make outer loop for x
and inner loop for y - and make a flag to check if you have some y tht is not devideble by...

and print only x for which flag is not set

6. Originally Posted by alperen1994
i want the all numbers between 0-50000 that can divided with all numbers between 0-11
I take that as a "yes, but the 5000 should be 50000", in which case note that the program that you posted has 5000 whereas you want 50000.

Basically, a fix to your current code would be to make the loop that loops from x in the range [0, 50000) be the outer loop. In the inner loop, you check for divisibility, and if you find that x % y != 0, then you know that the current value of x should not be printed. If the inner loop is done and at no point is x % y != 0, then you print the current value of x and move on to the next.

7. Or determine a step by which to increment the number and just print the values.

If I'm not mistaken all these numbers are 0 and 27720.

8. Originally Posted by anon
If I'm not mistaken all these numbers are 0 and 27720.
hmm... how did you get 27720? I reasoned that if we accounted for multiples of 8, we would cover 2 and 4. Unfortunately, I computed it as 3 * 8 * 5 * 7 * 9 = 7560, forgetting that the same reasoning that applies for 8 covering for 2 and 4 applies for 9 covering for 3. We do not need to worry about 6 and 10 since they are covered by 8, 9 and 5. As such, the sequence would be multiples of 8 * 9 * 5 * 7 = 2520, and brute force testing confirms that.

9. I also included 11...

10. Originally Posted by anon
I also included 11...
The OP didn't. Whether that's a flaw in the posted code or the posted explanation will have to wait for OP.

Edit: To be more clear, the OP said "between 0-11" and checked 1, 2, 3, 4, 5, 6, 7, 8, 9, and 10. Whether 11 was supposed to be included I can't say.