Visit our sponsor Granny's Eggs  
Home
Microsoft Interview Process
HR Questions
Technical Questions
Puzzles/Riddles
Resume Tips and Template
Discuss
Question to Interviewer
Interview Tips
Term Of Use
Site Feedback


Program the Fib Sequence without recursion

0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584, 4181, 6765, 10946, 17711, 28657, 46368, 75025, 121393, 196418, 317811…

 

Program it for efficiency and precision.  Also nice and eloquent solutions are good too. 


 

Comments:

code
By kanakshila on Sunday, June 24, 2007 (UMST)

Fibonacci Series

#include<iostream.h>
#include<conio.h>

main()
{
   const unsigned long limit=4294967295;
   unsigned long next=0;
   unsigned long last=1;
   long sum;

   clrscr();

   cout<<"\n\nThis program will print the Fibonacci series :\n\n ";
   while(next<limit/2)
   {
      cout<<last <<"   ";
      sum=next+last;
      next=last;
      last=sum;
   }
  

 

New Articles
  • Program the Fib Sequence without recursion

  • Everyone learns how to do recursion with the Fibonacci sequence in Programming 101. Do it programmatically without recursion.

  • Implement and test a memcpy function
    Given a function header (in fact an out-of context function call):
    memcpy(src, dst, size)
    Write an implementation and test cases.
    Be sure to ask additional questions on what exactly the function does and the range of arguments as well.



  • Implement an allocator
    Implement a memory allocator, i.e. malloc function, free function and all data structures, needed for that.

  •  

    Most Popular Articles
  • Crazy Guy On The Airplane

  • A line of 100 airline passengers is waiting to board a plane. they each hold a ticket to one of the 100 seats on that flight.

  • Question: Tell me about yourself.
    Many candidates, unprepared for the question, skewer themselves by rambling, recapping their life story, delving into ancient work history or personal matters.

  • What are your greatest weaknesses
    Beware - this is an eliminator question, designed to shorten the candidate list. Any admission of a weakness or fault will earn you an “A” for honesty, but an “F” for the interview.

  •  





  •