Lösungsvorschlag 3.3.-Aufgabe 1: Unterschied zwischen den Versionen

Aus ComeniusWiki
Wechseln zu: Navigation, Suche
(Die Seite wurde neu angelegt: „<pre> public void fibonacci1(){ long s=0; long t=1; long u=0; System.out.println("0"); System.out.println("1"); while(u<100000) { u=s+t; if (u<100000){System.out…“)
 

Aktuelle Version vom 28. September 2013, 11:33 Uhr

public void fibonacci1(){
long s=0; long t=1; long u=0;
System.out.println("0");
System.out.println("1");
while(u<100000) {
u=s+t; 
if (u<100000){System.out.println(u);}; 
s=t; t=u;};
}

Hinweis: Ohne die if-Bedingung würde die erste Fibonacci-Zahl >100000 auch noch ausgegeben.