i value can't be 4.
In question, we can see i is incremented as i=i*(i+3)/2.
The condition is
!( ( (i+1) mod 5==0 ) || ( (i+7) mod 6==1 ) || ( (i-27)mod 7 ==2 ) )
The iteration of the above loop is explained using the table below.
Initially, count value is 0 and each time when condition is true, then c is incremented as c++.
When condition will be true, print value = i mod 17.
When condition will be true, then i is incremented as i=i*(i+3)/2.
i value |
condition |
print value |
incremented i |
count |
1 |
True |
1mod17=1 |
1(1+3)/2=2 |
1 |
2 |
True |
2mod17=2 |
2(2+3)/2=5 |
2 |
5 |
True |
5mod17=5 |
5(5+3)/2=20 |
3 |
20 |
True |
20 mod 17=3 |
20(20+3)/2=230 |
4 |
230 |
True |
230 mod 17=9 |
230(230+3)/2= 26795 |
5 |
26795 |
True |
26795 mod 17=3 |
26795(26795+3)/2=359026205 |
6 |
359026205 |
True |
359026205 mod 17=9 |
359026205(359026208+3)/2=64449908476890320 |
7 |
64449908476890320 |
|
|
|
|
|
|
|
|
|
So till now it is okay, but it will take huge calculations further. So we cant say which option is correct.
So see the logic of this code but don't worry that how to do this in exam,because in GATE they are not going to give this type of “bakwasss” questions.