28 Jun 2011

Rekursif

Is the ability of a recursive routine to call itself. Recursive definition is actually contained in the procedures and functions. The difference is that the recursive call to itself can be, but the procedures and functions must be called by the caller procedures and functions. Recursive programming techniques are important and some programming languages ​​support the existence of this recursive process.

The following is an example of a recursive program uses
jeliot.io.*;


import jeliot.io.*;

public class hitung {
 
    public void input(){
    System.out.println("
determine the value n:");
    n=Input.readInt();
    }
    public void proses(){
           jumlah=0;
           total=0;
           rumus=-1;
    for(int j=1; j<=n; j++)
     {
     rumus=(rumus*(-1));
     total=rumus/j;
     jumlah+=total;
     if(j==1)
     System.out.println(+total);
     if(j>1)
     System.out.println(+total);
    
     System.out.println("
sum of series = "+number);
     }
     }
private int n;
private float rumus,jumlah,total;

    public static void main() {
       hitung h=new hitung();
       h.input();
       h.proses();

    }
}

Tidak ada komentar:

Posting Komentar