/  *  *
*
* Beschreibung
* Gibt Fibonacci Reihe bis 100 aus
* @version 1.0 vom 02.03.2012
*  /
 
public class fibonacci
{
public static void main( String[] args )
{
System.out.println( "Hier sehen sie die Fibonacci - Reihe von 1 - 100:" ) ;
for( int n = 1;n< = 11;n +  +  )
{
System.out.println( fibonacci( n )) ;
}
}
static int fibonacci( int n )
{
if( n< = 2 )
     {
     return 1;
     } else
     {
     return fibonacci( n - 1 ) + fibonacci( n - 2 ) ;
     }
     }
     }
 

Diesen Code in Original-Formatierung anzeigen
goto line:
Compare with:
text copy window edit this code post new code