import javax.swing.*;
class SegitigaPascal_Rekursif
{
static int segitiga_pascal(int level, int column)
{
if (level == 0 || column == 0 || level == column) return 1;
else return segitiga_pascal(level-1, column) + segitiga_pascal(level-1, column-1);
}
public static void main(String[] args)
{
int input2 = Integer.parseInt(JOptionPane.showInputDialog("Input Value "));
for (int i = 0; i <= input2-1; i++)
{
for (int j = 0; j <= i; j++)
{
System.out.print(" "+segitiga_pascal(i,j));
}System.out.println();
}
}
}
// use "SegitigaPascal_Rekursif.java" for file name
Ads 970x90
Jumat, 09 Maret 2012
Segitiga Pascal ( Java )
Editor
Aguez stw
Published
3/09/2012 07:44:00 AM
Related Posts
Load comments
Langganan:
Posting Komentar (Atom)