Hi All,
Can anyone tell about how to create a FIBONACCI series in VB.Net and C#
Thanks in Advance,
Veeru 3 11972
"Michael Nemtsev" <ne*****@msn.co mwrote in message
news:17******** *************** ****@msnews.mic rosoft.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 OverflowExcepti on();
return f;
}
public static int Main(string[] args)
{
Console.WriteLi ne(FibI(1000 * 1000 * 1000));
Console.ReadKey ();
return 0;
}
}
David This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
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, and
when the numbers get too large it maxes out the int and I can't count
any higher. I am trying to use extremely large numbers, I would like
to use up to 10^50 or so. So my question is how do I do this? I'm just
learning the language and I...
|
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 of the code produced by various compilers.
===========================================================
Windows 2000 Professional Ver 5.0 Build 2195 Service Pack 2
Intel(R) Celeron(R) CPU 1.70 GHz
GNU time 1.7 (to get the real time used)
|
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
|
by: Niks |
last post by:
Can anybody explain me what is a "Fibonacci search"?
even an URL will do.
Thanks for reading.
|
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 not?
Or, another way to look at this is that: Would anyone of you think it
is worth a while to find out if there is any location on earth with
the set of longitude and latitude numbers that coincides with the
Fibonacci series?
As I see it, if...
| |
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 newsgroup there is an ongoing discussion about the famous
fibonacci sequences, and a fine program written by a poster got my
attention so just for fun I wrote one myself and put it on the web just
about two days ago. It can be found on the site
...
|
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;
std::cout << a/b << std::endl;
|
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 errors:
|
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 creates a character string containing
the first n Fibonacci numbers - F(n) = F(n - 1) + F(n - 2), F(0) =
F(1) = 1 -, separated by comma. n should be given as an argument to
the program. The recursive function should only take one parameter, n,
and...
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
| |
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |