Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package pkg;
- class Pascal {
- int n;
- Pascal()
- {
- System.out.print("\tDefault Const called!\n");
- n = 3;
- }
- Pascal(int n)
- {
- System.out.print("\tParameterized Const called!\n");
- this.n=n;
- }
- int nCr(int n, int k)
- {
- int r = 1;
- if(k > n - k)
- k = n - k;
- for(int i = 0; i < k; ++i)
- {
- r *= (n - i);
- r /= (i + 1);
- }
- return r;
- }
- void printPascal()
- {
- for(int l = 0; l < n; l++)
- {
- for(int i = 0; i <= l; i++)
- System.out.print(" "+ nCr(l,i));
- System.out.println();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement