473,387 Members | 1,540 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

FIBONACCI

Hi All,

Can anyone tell about how to create a FIBONACCI series in VB.Net and C#

Thanks in Advance,

Veeru

Nov 26 '06 #1
3 11935
Hello veeru,

http://www.google.com/codesearch?q=Fibonacci+C%23&hl=en

vHi All,
v>
vCan anyone tell about how to create a FIBONACCI series in VB.Net and
vC#
v>
vThanks in Advance,
v>
vVeeru
v>
---
WBR,
Michael Nemtsev [C# MVP] :: blog: http://spaces.live.com/laflour

"At times one remains faithful to a cause only because its opponents do not
cease to be insipid." (c) Friedrich Nietzsche
Nov 26 '06 #2
Hello veeru,

A little bit better search http://www.google.com/codesearch?as_...n&as_lang=c%23

vHi All,
v>
vCan anyone tell about how to create a FIBONACCI series in VB.Net and
vC#
v>
vThanks in Advance,
v>
vVeeru
v>
---
WBR,
Michael Nemtsev [C# MVP] :: blog: http://spaces.live.com/laflour

"At times one remains faithful to a cause only because its opponents do not
cease to be insipid." (c) Friedrich Nietzsche
Nov 26 '06 #3


"Michael Nemtsev" <ne*****@msn.comwrote in message
news:17***************************@msnews.microsof t.com...
Hello veeru,

A little bit better search
http://www.google.com/codesearch?as_...n&as_lang=c%23

vHi All,
vvCan anyone tell about how to create a FIBONACCI series in VB.Net and
vC#
vvThanks in Advance,
vvVeeru
v>
While those are correct implementations of the fibonacci sequence (it's a
sequence (http://en.wikipedia.org/wiki/Sequence), not a
series(http://en.wikipedia.org/wiki/Series_...matics%29))the vast
majority are recursive implementations, that because of the limited stack
space, only work for the first few numbers in the sequence, and perform
really poorly.
Here's a little sample with a recursive and an iterative implementation of
fibonacci. Play around with it so see how much better the iterative
implementation is.
class Program
{
static int FibR(int n)
{
if (n < 2)
return 1;
else
return FibR(n - 1) + FibR(n - 2);
}
static long FibI(long n)
{
if (n < 2)
return 1;

long fp = 1;
long fpp = 1;
long f = 0;
for (int i = 2; i < n; i++)
{
f = fp + fpp;
fpp = fp;
fp = f;
}
if (f < 0)
throw new OverflowException();

return f;
}

public static int Main(string[] args)
{
Console.WriteLine(FibI(1000 * 1000 * 1000));
Console.ReadKey();
return 0;
}
}
David

Nov 26 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

28
by: dleecurt | last post by:
Hello, I have a small problem, I am trying to write a program that will calculate the Fibonacci number series, and I have the code complete with one problem. I used a long in to store the numbers,...
0
by: Alex Vinokur | last post by:
An algorithm which computes very long Fibonacci numbers http://groups.google.com/groups?selm=bnni5p%2412i47o%241%40ID-79865.news.uni-berlin.de was used as a performance testsuite to compare speed...
5
by: Lance | last post by:
What is the correct STL libraries to implement in order to have a Fibonacci Heap created? I am creating an algorithm which would use a Fibonacci Heap. Thanks, Lance
5
by: Niks | last post by:
Can anybody explain me what is a "Fibonacci search"? even an URL will do. Thanks for reading.
4
by: YS Sze | last post by:
If you know the exact longitude and latitude for a specific location, would anyone think it'd make any sense to find out if this set of location numbers is really part of the Fibonacci series or...
12
by: CII | last post by:
Hi everybody. I've been reading posts a year old about the fibonacci series right on this newsgroup, and while it's not directly games related, I'll share my own notes as well. On another...
14
by: felixnielsen | last post by:
Im actually kinda embarassed to ask this question... @code start #include <iostream> int main() { unsigned long long a = 1; unsigned long long b = 1; for (int i = 0; i < 45; i++) { a += b;...
3
by: greek | last post by:
Hi! I hav to generate fibonaaci series using recursion: 0,1,1,2,3,5,8,18,21... whr fibonacci(0)=0 fibonacci(1)=1 fibonacci(n)=fibonacci(n-1)+fibonacci(n-2) ive witten the code but having 2...
13
by: mac | last post by:
Hi, I'm trying to write a fibonacci recursive function that will return the fibonacci string separated by comma. The problem sounds like this: ------------- Write a recursive function that...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.