Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.*;
- public class Pascal{
- public static void main(String[] args){
- Scanner console = new Scanner(System.in);
- int n = console.nextInt();
- for (int i = 1; i<=n; i++){
- for (int x = 1; x <= 2*(n)-2*i; x++) {
- System.out.print(" ");
- }
- for (int r=0; r<=i-1; r++) {
- long c = fact(i-1)/(fact(i-1-r)*fact(r));
- System.out.printf("%-4d",c);
- }
- System.out.println();
- }
- }
- public static long fact(int n){
- long f=1;
- for(int i=n;i>=1;i--) {
- f*=i;
- }
- return f;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement