Created
February 20, 2015 03:49
-
-
Save dineshrajpurohit/8cf43ef44fd7f1ee513c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Dinesh | |
* | |
*/ | |
//package com.dinesh.tutorials; | |
public static void pascal(int n){ | |
int[][] pas = new int[n][]; | |
for(int i=0; i<n;i++){ | |
pas[i] = new int[i+1]; | |
pas[i][0] = 1; | |
System.out.print(pas[i][0]+ " ");; | |
for(int j=1; j<i; j++){ | |
pas[i][j] = pas[i-1][j-1]+pas[i-1][j]; | |
System.out.print(pas[i][j]+" "); | |
} | |
pas[i][i] = 1; | |
System.out.print(pas[i][i]+" "); | |
System.out.println(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment