NetVision-Technik

NetVision-Technik (http://www.netvision-technik.de/forum/index.php)
-   C / C++ (http://www.netvision-technik.de/forum/forumdisplay.php?f=59)
-   -   Berechnung der fibonacci Reihe (http://www.netvision-technik.de/forum/showthread.php?t=2822)

Solstice 08.02.2009 22:50

Berechnung der fibonacci Reihe
 
Ich mach mal so n Schnippselthread auf...


Da mal eine funktion für die berechnung von der fibonacci Reihe

Code:

void fibonacci (int limit = 100)
{
  int temp1 = 0;
  int temp2 = 0;
  int erg = 0;

  while (erg < limit)
  {
    cout << erg << endl;  // hier steckt jeweils das Ergebnis drin
    erg = temp1 + temp2;
    temp2 = temp1;

    if (erg == 0)
      erg++;

    temp1 = erg;

  }

}



Alle Zeitangaben in WEZ +1. Es ist jetzt 11:09 Uhr.

Powered by vBulletin® Version 3.8.9 (Deutsch)
Copyright ©2000 - 2024, vBulletin Solutions, Inc.