| | |
Fibonacci number
![]() |
•
•
Join Date: Oct 2005
Posts: 1
Reputation:
Solved Threads: 0
Hi!
I want to write a program to calculate Fibonacci number NON-RECURSIVE
I tried many times but I could not get the result(0-1-1-2-3-5-8...).
Please help me.
I want to write a program to calculate Fibonacci number NON-RECURSIVE
I tried many times but I could not get the result(0-1-1-2-3-5-8...).
Please help me.
C Syntax (Toggle Plain Text)
#include <stdio.h> unsigned int f(int n) { int i; unsigned int last=0,current=1; int result; for(i=1; i<=n; i++) { last+=current; //???????? printf("-%d",last); } return last; } void f_print(int n) { printf("%d\n",n,f(n)); } int main(void) { f_print(10); return 0; }
Code: http://www.google.com/search?num=30&...2B&btnG=Search
They all do the same thing. So I'm sure you can just pick one and use that. Or, compare it with yours to see what you did wrong.
They all do the same thing. So I'm sure you can just pick one and use that. Or, compare it with yours to see what you did wrong.
![]() |
Similar Threads
- Fibonacci Series (C++)
- Having problem generating Fibonacci sequence (C)
- Fibonacci Number (Assembly)
- Shell Sort w/ fibonacci numbers...HELP!!! Due Friday (C++)
Other Threads in the C Forum
- Previous Thread: Accessing To A Struct With A Given Pointer
- Next Thread: Basic Concept
| Thread Tools | Search this Thread |
#include * adobe ansi array asterisks binarysearch centimeter changingto char character cm convert copyimagefile cprogramme creafecopyofanytypeoffileinc database dynamic execv feet fgets file floatingpointvalidation fork function getlogicaldrivestrin givemetehcodez global grade gtkwinlinux hacking histogram ide inches include incrementoperators infiniteloop input interest intmain() iso kernel keyboard kilometer license linked linkedlist linux list locate looping lowest matrix meter microsoft mqqueue number oddnumber opendocumentformat opensource openwebfoundation owf pattern pdf performance pointer posix power probleminc process program programming radix recursion recv recvblocked research reversing segmentationfault sequential single socket socketprograming socketprogramming standard strchr string suggestions systemcall test threads turboc unix urboc user variable voidmain() wab whythiscodecausesegmentationfault windowsapi





