THINK - Strange Pattern (Easy)


Mr. X is new to programming and he tries to make a function to print out the x-th fibonacci numbers. For x=1 and x=2, the function prints out 2 and 3 respectively. But for some reason, every number after that also prints out 3.

In the end, Mr. X given up on fixing the function and instead challenges you to recreate the function that he created. Since Mr. X is new to programming, he only wants you to do a single statement in the function so he can understand. The statement must also not contain any letter but 'x'. Mr. X doesn't understand bitwise, relational, logical, and conditional/ternary operators, so don't use that.

Mr. X has given you his code for you to edit, but you can only edit a certain part of the code.

#include <stdio.h>

int count(int x){

return edit this part;

}

int main(){

for( int i=1 ; i-1001 ; i++ ) printf("%d %d\n",i,count(i));

return 0;

}

#include <stdio.h>
int count(int x){
return (x+1)%x+2
}
int main(){
for( int i=1 ; i-1001 ; i++ ) printf("%d %d\n",i,count(i));
return 0;
}M

Mr. X will first check the correctness of the output. If the output is correct, he then will check the code. If he finds anything that he doesn't understand, the result will be "compilation error". Changing the code other than the allowed part may also result in a compile error.

DO NOT USE ANY WHITESPACE ON THE EDITED PART

Input

No input.

Output

1 2
2 3
3 3
4 3
... and so on ...
998 3
999 3
1000 3 

 

Click here to see all problems in this series!


hide comments
joeyndchandler: 2018-07-09 04:33:55

should think of it like a maths question like f(1)=2,f(2)=3,f(3)=3............................. and so on think how you will get 3 after a number greater than or equal to 2.....:)

narek: 2017-09-07 21:37:56

the edited part should be one word (no space formating)

himanshu_12345: 2017-06-25 10:56:33

need little brain storming


keshav72: 2017-06-19 08:42:13

Just copied the code and made changes to 'edit this part'. Runs fine on every IDE, still showing compilation error.
please help- 19638115 solution code

Mangesh : 2017-05-26 11:31:14

Good one.

Last edit: 2017-05-26 11:35:38
bnzhaxx: 2017-04-22 03:07:18

just. edit. the. code!

kass_97: 2017-01-12 10:38:53

Don't even make a single change in Mr.X's code....all you need to do is find the 'edit part' and done, cost me 1 CE

sahil_1994: 2016-08-30 22:17:47

can the statement contain constant numbers?

sahil_1994: 2016-08-30 21:44:39

help please! My code is running fine in ideone but shows compilation error in submission??

Last edit: 2016-08-30 21:45:16
square1001: 2016-08-05 13:37:19

Interesting :-)


Added by:Andy
Date:2013-05-24
Time limit:1s
Source limit:250B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:C++ 4.3.2
Resource:own problem