SWjtools
Class SWmathfor

java.lang.Object
  |
  +--SWjtools.SWmathfor

public class SWmathfor
extends java.lang.Object

Sigrid Wehner's mathematische Formeln

Version:
30.4.2002

Constructor Summary
SWmathfor()
           
 
Method Summary
 int anzahl()
          Zählt die Rechenschritte des Algorithmus.
 long faki(int n)
          Berechnet n-FAKULTÄT iterativ.
 long fakr(int n)
          Berechnet n-FAKULTÄT rekursiv.
 int fiboi(int n)
          Berechnet FIBONACCI-Zahlen iterativ.
 int fibor(int n)
          Berechnet FIBONACCI-Zahlen rekursiv.
 void init_anzahl()
          Setzt internen Zähler der Rechenschritte auf Null.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SWmathfor

public SWmathfor()
Method Detail

fakr

public long fakr(int n)
Berechnet n-FAKULTÄT rekursiv.
(Beispiel für elegantes Verfahren)
Parameters:
n - natürliche Zahl
Returns:
n! (bzw. -1, falls n negativ war)

faki

public long faki(int n)
Berechnet n-FAKULTÄT iterativ.
Parameters:
n - natürliche Zahl
Returns:
n! (bzw. -1, falls n negativ war)

fibor

public int fibor(int n)
Berechnet FIBONACCI-Zahlen rekursiv.
Dieses ist ein Beispiel für schlechte Anwendung von Rekursion, da die Anzahl der Rechenschritte gigantisch anwächst mit steigendem n!!!
Parameters:
n - Es soll n-te Fibonacci-Zahl berechnet werden.
Returns:
n-te Fibonacci-Zahl (bzw. -1, falls n<0)

fiboi

public int fiboi(int n)
Berechnet FIBONACCI-Zahlen iterativ.
Dieses ist ein Beispiel dafür, dass der iterative Algorithmus effektiver ist als die Rekursion!!!
Parameters:
n - Es soll n-te Fibonacci-Zahl berechnet werden.
Returns:
n-te Fibonacci-Zahl (bzw. -1, falls n<0)

anzahl

public int anzahl()
Zählt die Rechenschritte des Algorithmus.

init_anzahl

public void init_anzahl()
Setzt internen Zähler der Rechenschritte auf Null.