Suite de Fibonacci (1)⚓︎

Les premiers termes de la suite de Fibonacci sont :

\[0, 1, 1, 2, 3, 5, 8, 13, 21, 34, \cdots\]
  • Les deux premiers termes sont \(0\) et \(1\).
  • À partir du troisième, un terme est la somme des deux précédents.

Écrire une fonction telle que fibonacci(n) renvoie le terme d'indice \(n\) de la suite de Fibonacci.

On demande ici de programmer une fonction très élémentaire, pour des valeurs de \(n\) inférieures à \(25\).

Exemples :
>>> fibonacci(0)
0
>>> fibonacci(3)
2
>>> fibonacci(7)
13
>>> fibonacci(8)
21
>>> fibonacci(9)
34
>>> fibonacci(4)
3

On a bien fibonacci(9) égal à fibonacci(7) + fibonacci(8)

###(Dés-)Active le code après la ligne # Tests (insensible à la casse)
(Ctrl+I)
Tronquer ou non le feedback dans les terminaux (sortie standard & stacktrace / relancer le code pour appliquer)
Si activé, le texte copié dans le terminal est joint sur une seule ligne avant d'être copié dans le presse-papier
Évaluations restantes : 5/5
.65038.9875.128013.9888lS]Àet-d5f1umaèg,_/R=Vin 6@)yàqPhcïL[(bsx.p;r4jC'0"ov+THw3êOk:é *2I030f0c0d0l0u080L0,0F080l0L0L0s0W0d0u0O0W020w030L0j0k0k0l0Q0A02090X080j130X0v0,000l0k0O0P0,0r0c1d0Q0C0j0c0L030q1a1c1e1g180O02031L1E1O0q1L180f0u0Y0{0}0 110E0u0n0E081$0E0d16030?0K080c1X0~100W1#1%1(1%0d1.1:1,0d0Q1M0d0E0{1j0L0O0l0v110.0W1=1Z0W0h0^0c0v1r0c1,282a2f1@2i1:2l0k2n02060,0D0Q0X0O0X0L0u1m1o0;260Q0Q0c0F2I1E2p0v1M0q242U2123221-0f2r111(0v2k2F1,1U1W0|1?2'0u2)0v0X2-1,0O2N1M2S2U2~19291o2/2g2@0Q1d08160i2R3217312q341@3638160.3c2a3e2S2%0W3j0l39020%3n2T183q3h113t3v0R3y3p323r3E160g3H1P2|1E2-2X0f232$3C0W0F2^2x0:1V1M2{0c2}3d3O3Z0;3*3g1Y1@0)160;0h3H0,3f333;3D0h162i0K1n0l0F0F0u3O3B3~0W15020J493J3X0v160v4g3:2:4c160z0*3H0w0,4v3{4a4o3?020u3_1F3d4x4h4b4j024l4E3o4G4n2g0X1600080d0P3`3|3r0k0u3l4m3}4o4d4s4M3z4w4-4O4'2g4A2N0d0j0Q4L2~4/3K4k4t4-4Y3X4A0c0_0c4%3r4)4 4.4v514b4=0=4^4`4F5d4o4J424446484+3/4:1@4d4f5r5k354~5r4|3X4R020e4X4y2g4!3a573X4d0z5H4H4o5E0Z5Q4P3i410u432l5p5M4b5v5%5l5A4{5y1@5E5G5B5-115K023m5x5I5u4q4t1E3-3)3P610q3S1E0d3U662!2V0l1/633S1K5s3r2N0k0p0h0l0)0c0p0E0%161w1y1A1C0,4*301R3e1L0T0=0d1;0Y0c0Q2G1n0,1C0d0,210m0`2G1s1:0,0B0,0+0F0Q0u2N0o0,1d0u0`0;0Y0u2k6P6R0`2u6G6X0,290Q130Q0,2K03604K0,0s0,0.3N0q726N0v6.2C0v0N0,0H6x0k0'2w0`0F3u0F0j0_0,0L1n6P0;1d0v0f0+6,1;6=0,2@0k0K2N0j0L6x0h0X6+0N1P3e0E0i0,0u0f116I6K0u1n0e2H6J0l136I160t6J6L1o2H0+0Q7)1V560l3r0E0c0l0;0Q2(3?0,0E2N0h11017Z7/7%6G7?7*2n6Q2H1:110D6J7y6:0,811605041E0l2U7T3e2-7{1)1{1*2o5R2g2t2k2m162z096#146P0D0A241n3O3(5s2 3+725=0W4A3^5V5t3 5Y5!45475)2g5(5`8E5X4K8-5|024r5a5c5{3D160l8@114d0o8%4}020K955D160s994b5@0V914p02945;8}0W5@3b5r4u4w8Z4A7N0Q9d5*4B9x4Q0$162=9A3i0K167?0v0n568:5W92165w309m4J5i3o8Z5O6z3d9r5b8Z4J909N8'9i9k5,9T16989l8;115E9c9;9O3s9/9h939F8~029(9S9=0W5T9h4J9:2~9#5C5e9I5g4_9 9{a15~793!2U8U3R3%6g0/087t0U0l0n2H6 1;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