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!


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

hide comments
2016-01-21 08:26:20 Andy
@Arnab try to improve your reading skill.
2016-01-08 06:18:27 Arnab Animesh Das
Stupid problem. There are many ways to go about it, but it has to be the one which the problem wants.
2015-01-05 07:18:00 Stanley Pham
Take 3 *compile error* because of MY stupid reformating...
2014-12-30 08:00:55 ThunderStorm
can the statement contain arithematic operations?

Last edit: 2014-12-30 08:01:10
2013-12-28 19:16:37 Bhavik
nice and simple riddle:)
© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.