30.01.2014 Aufrufe

Translation Studies for Information Technologies V3- 02.03.11

Translation Studies for Information Technologies V3- 02.03.11

Translation Studies for Information Technologies V3- 02.03.11

MEHR ANZEIGEN
WENIGER ANZEIGEN

Erfolgreiche ePaper selbst erstellen

Machen Sie aus Ihren PDF Publikationen ein blätterbares Flipbook mit unserer einzigartigen Google optimierten e-Paper Software.

Fakultätsfunktion in Java<br />

Die Definition der Fakultätsfunktion in Java kann zum Beispiel so aussehen:<br />

static int faculty ( int n ) {<br />

if ( n == 0 )<br />

return 1;<br />

else<br />

return n * faculty( n-1 );<br />

}<br />

Aufgrund der Sichtbarkeitsregeln in Java kann der Name einer Methode im Rumpf<br />

derselben Methode benutzt werden<br />

Der Aufruf der Fakultätsfunktion mit dem Wert 4 führt zu folgender Aufrufkette<br />

faculty( 4 )<br />

→ faculty( 4 * faculty( 3 ) )<br />

→ faculty( 4 * faculty( 3 * faculty( 2 ) ) )<br />

→ faculty( 4 * faculty( 3 * faculty( 2 * faculty( 1 ) ) ) )<br />

→ faculty( 4 * faculty( 3 * faculty( 2 * faculty( 1 * faculty( 0 ) ) ) ) )<br />

= 24<br />

INF2 – <strong>Translation</strong> <strong>Studies</strong> <strong>for</strong> In<strong>for</strong>mation <strong>Technologies</strong> <strong>V3</strong>- <strong>02.03.11</strong><br />

33

Hurra! Ihre Datei wurde hochgeladen und ist bereit für die Veröffentlichung.

Erfolgreich gespeichert!

Leider ist etwas schief gelaufen!