Skip to content

Fall out, Codes!

Let all the problems bow before your patience and stubbornness!

Primary Menu

  • Home
  • About Me

Category Fibonacci_

n th fibonacci number-Iterative

October 17, 2017October 17, 2017Arunima Mandal Leave a comment
#include <iostream>

using namespace std;

int main()
{
    int n,i,first,second,third;
    for(;;)
    {
        cin>>n;
        first=0;
        second=1;

        for(i=0;i<=n-2;i++)
        {
            third=first+second;
            first=second;
            second=third;
        }
        cout<<"The Fibonacci number for "<<n<<" is "<<third<<endl;
    }
    return 0;
}


Category

  • 0/1 Knapsack
  • Ad-hoc
  • Algorithmic Codes
  • Array
  • Base conversion
  • Basic Data Structure
  • Basic Math
  • Bellman Ford
  • BFS
  • BFS in 2D grid
  • Binary Search
  • Binary Tree
  • BIT
  • Co-prime
  • Coin Change
  • Cummulative Sum
  • Deque
  • DFS
  • DFS in 2D grid
  • Dijkstra
  • Disjoint Set / Union Find
  • Divisor
  • DP
  • Factorial
  • Fibonacci_
  • GCD,LCM
  • Geometry
  • Goldbach's Conjecture
  • Graph
  • Hashing
  • Krushkal's algorithm
  • Lazy Propagation
  • Light OJ
  • Linked List
  • Map
  • Matrix Exponentiation
  • Minimum Spanning Tree
  • MO's algortihm (SQRT decomposition)
  • Modular Arithmatic
  • nCr
  • Number Theory
  • Number_Theory
  • Pair
  • Prim's algorithm
  • Prime
  • Recursive function
  • Searching
  • Segment Tree
  • Set
  • Sorting
  • SPOJ
  • Stack
  • STL
  • String Manipulation
  • Topsort
  • Tree
  • Trie
  • Uncategorized
  • Useful tricks!
  • UVa
  • vector
Blog at WordPress.com.
  • Subscribe Subscribed
    • Fall out, Codes!
    • Already have a WordPress.com account? Log in now.
    • Fall out, Codes!
    • Subscribe Subscribed
    • Sign up
    • Log in
    • Report this content
    • View site in Reader
    • Manage subscriptions
    • Collapse this bar