PR1/TestProgs/BinomialCoefficient.java

32 lines
444 B
Java

public class BinomialCoefficient{
public static void main (String[] args){
int n = Integer.parseInt(args[0]);
int z = 1; // Zeilen Schleife
int s = 1; // Spalten Schleife
//Ausgabe
for (z = 1; z < n; z++){
long a = 1; // Variable zur Berechnung
for (s = 1; s <= z ; s++){
System.out.print(a + " ");
if (s < z){ //Nicht durch 0 teilen
a = a * (z - s)/(s + 1);
}
}
System.out.println(); //Neue Zeile
}
}
}