eolymp
bolt
Try our new interface for solving problems
Problems

Fibonacci Sequence

published at 11/13/22, 7:42:32 am

Eyni meseleni 1000 defe verirler

published at 1/22/24, 3:54:37 pm

include <bits/stdc++.h>

define ll long long

using namespace std; ll f(ll n){ if(n==0){ return 0; } else if(n==1){ return 1; } else { return f(n-1)+f(n-2); } } int main() { ll n; cin>>n; cout<<f(n); } napim easey siadd

published at 4/3/24, 2:15:14 am

import java.util.Scanner;

public class Main { public static void main(String[] args) { Scanner scan = new Scanner(System.in);

    long i, a = 0, b = 1, c = 0;

    i = scan.nextLong();

    for (long j = 1; j <= i; j++) {
        c = a + b;
        a = b;
        b = c;
    }

    System.out.println(a);
}

}