| | |
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 |
* adobe ansi api array asterisks binarysearch calculate centimeter char character cm convert copyanyfile copyimagefile copypdffile cprogramme createcopyoffile createprocess() csyntax directory feet fflush fgets file floatingpointvalidation fork frequency function getlasterror getlogicaldrivestrin givemetehcodez global graphics gtkgcurlcompiling gtkwinlinux hacking highest homework i/o inches infiniteloop interest intmain() kilometer km linked linkedlist linux linuxsegmentationfault list locate logical_drives match meter microsoft mqqueue mysql number oddnumber odf open opendocumentformat openwebfoundation owf pattern pdf performance posix power probleminc program programming pyramidusingturboccodes read recv recvblocked repetition scanf scheduling segmentationfault send single socketprograming socketprogramming stack standard strchr string suggestions systemcall unix urboc user variable voidmain() wab whythiscodecausesegmentationfault win32api windows.h





