Fibonacci

print n-th fibonacci number
f_0=1
f_1=1
f_(n+2)=f_(n+1)+f_n

IN

0

OUT

1

IN

1

OUT

1

IN

10

OUT

89

IN

100

OUT

573147844013817084101

IN

1000

OUT

70330367711422815821835254877183549770181269836358732742604905087154537118196933579742249494562611733487750449241765991088186363265450223647106012053374121273867339111198139373125598767690091902245245323403501

IN

10000

OUT

54438373113565281338734260993750380135389184554695967026247715841208582865622349017083051547938960541173822675978026317384359584751116241439174702642959169925586334117906063048089793531476108466259072759367899150677960088306597966641965824937721800381441158841042480997984696487375337180028163763317781927941101369262750979509800713596718023814710669912644214775254478587674568963808002962265133111359929762726679441400101575800043510777465935805362502461707918059226414679005690752321895868142367849593880756423483754386342639635970733756260098962462668746112041739819404875062443709868654315626847186195620146126642232711815040367018825205314845875817193533529827837800351902529239517836689467661917953884712441028463935449484614450778762529520961887597272889220768537396475869543159172434537193611263743926337313005896167248051737986306368115003088396749587102619524631352447499505204198305187168321623283859794627245919771454628218399695789223798912199431775469705216131081096559950638297261253848242007897109054754028438149611930465061866170122983288964352733750792786069444761853525144421077928045979904561298129423809156055033032338919609162236698759922782923191896688017718575555520994653320128446502371153715141749290913104897203455577507196645425232862022019506091483585223882711016708433051169942115775151255510251655931888164048344129557038825477521111577395780115868397072602565614824956460538700280331311861485399805397031555727529693399586079850381581446276433858828529535803424850845426446471681531001533180479567436396815653326152509571127480411928196022148849148284389124178520174507305538928717857923509417743383331506898239354421988805429332440371194867215543576548565499134519271098919802665184564927827827212957649240235507595558205647569365394873317659000206373126570643509709482649710038733517477713403319028105575667931789470024118803094604034362953471997461392274791549730356412633074230824051999996101549784667340458326852960388301120765629245998136251652347093963049734046445106365304163630823669242257761468288461791843224793434406079917883360676846711185597501
Login to submit solution


10 symbols pyth
Sat Oct 22 15:19:24 2016 Sait2000
eu,eGsGQU2
12 symbols pyth
Sat Oct 22 15:08:05 2016 Sait2000
J1VQ=Z~+JZ)J
14 symbols pyth
Mon Sep 19 14:45:10 2016 Sait2000
A,Z1VQA,H+GH)H
36 symbols ruby2.0
Sun Oct 5 20:32:51 2014 fl00r
#!/usr/bin/ruby2.0 -n
a=b=1
$_.to_i.times{a,b=b,a+b}
p a
37 symbols ruby2.0
Sun Oct 5 18:22:24 2014 fl00r
#!/usr/bin/ruby1.9.1 -p
a=b=1
$_.to_i.times{a,b=b,a+b}
$_=a
38 symbols python2
Sun Aug 10 19:16:56 2014 PFischbeck
a=b=1
exec"a,b=b,a+b;"*input()
print a
38 symbols python2
Mon Aug 11 00:05:35 2014 LLcoolNJ
a=b=1
exec'a,b=b,a+b;'*input()
print a
38 symbols python2
Sun Mar 22 21:09:57 2015 LLcoolNJ
a=b=1
exec"a,b=b,a+b;"*input()
print a
38 symbols ruby2.0
Sat Oct 22 15:11:13 2016 Sait2000
#!/usr/bin/ruby2.2 -n
a=b=1
1.upto($_.to_i){a,b=b,a+b}
p a
39 symbols ruby2.0
Sun Oct 5 03:00:39 2014 fl00r
a=b=1
$<.read.to_i.times{a,b=b,a+b}
p a
41 symbols ruby2.0
Sun Oct 5 00:06:13 2014 fl00r
a=b=1
ARGF.read.to_i.times{a,b=b,a+b}
p a
45 symbols python2
Sun Aug 10 19:17:17 2014 PFischbeck
a=b=1
exec("a,b=b,a+b;"*int(input()))
print a
46 symbols python3
Sun Aug 10 19:17:57 2014 PFischbeck
a=b=1
exec("a,b=b,a+b;"*int(input()))
print(a)
53 symbols perl
Sun Aug 10 18:50:49 2014 danieljabailey
#!/usr/bin/perl -np
use bigint;$r=1;$t=$o,$o+=$r,$r=$t for 0..$_;$_=$o
54 symbols perl
Sun Aug 10 18:50:07 2014 danieljabailey
#!/usr/bin/perl -np
use bigint;$r=1;$t=$o,$o+=$r,$r=$t for 0..$_;$_=$o;
55 symbols haskell
Thu Mar 12 12:00:44 2015 YoshikuniJujo
f@(_:t)=1:1:zipWith(+)f t
main=interact$show.(f!!).read
67 symbols perl
Tue Sep 16 00:32:28 2014 maxymania
use bigint;$_=<>;s/\s//g;$r=1;$t=$o,$o+=$r,$r=$t for 0..$_;print$o;
75 symbols python3
Tue Aug 19 20:09:54 2014 z423x5c6
def f(a,b,c):
 while a:a,b,c=a-1,c,b+c
 return c
print(f(int(input()),0,1))
78 symbols python3
Sun Aug 10 18:13:47 2014 z423x5c6
def f(a,b,c):
 while a:
  a,b,c=a-1,c,b+c
 return c
print(f(int(input()),0,1))

View all solutions