C, 224 229 227 chars - print n
'th fibonacci or 2^n
C, 224 229 227 chars - print n
'th fibonacci or 2^n
Golfed up:
Golfed up:
#import <Foundation/Foundation.h>
typedef unsigned long long f;f main(int c,char*v[]){f n=strtoull(v[1],(char**)v[2],10)-1;f x=(c>2&&++n==0)?0:1;f y=0;while(n--!=0&&x+y>=x&&x>0){f z=x;c>2?x+=y=z:(x+=y,y=z);}printf("%llu\n",x);}
#import <Foundation/Foundation.h>
typedef unsigned long long f;f main(int c,char*v[]){f n=strtoull(v[1],(char**)v[2],10)-1;f x=(c>2&&++n==0)?0:1;f y=0;while(n--!=0&&x+y>=x&&x>0){f z=x;c>2?x+=y=z:(x+=y,y=z);}printf("%llu\n",x);}
Readable :
Readable:
#import <Foundation/Foundation.h>
typedef unsigned long long f;
f main(int c,char*v[]){
f n=strtoull(v[1],(char**)v[2],10)-1;
f x=(c>2&&++n==0)?0:1;
f y=0;
while(n--!=0&&x+y>=x&&x>0){
f z=x;
c>2?x+=y=z:(x+=y,y=z);
}
printf("%llu\n",x);
}
#import <Foundation/Foundation.h>
typedef unsigned long long f;
f main(int c,char*v[]){
f n=strtoull(v[1],(char**)v[2],10)-1;
f x=(c>2&&++n==0)?0:1;
f y=0;
while(n--!=0&&x+y>=x&&x>0){
f z=x;
c>2?x+=y=z:(x+=y,y=z);
}
printf("%llu\n",x);
}