repl.it
@Wilmor21/

pascaltriangle

Java

No description

fork
loading
Files
  • Main.java
Main.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
class Main {
  public static void main(String[] args) {
    System.out.println(pascal(0,0));
    System.out.println(pascal(7,2));
    System.out.println(pascal(7,3));
  }

  public static int pascal(int row, int column)
  {
    if(column>row)
    return 0;
    if(column<0)
    return 0;
    if(row<=1)
      {
        return 1;
      }
      else{
        return pascal(row-1,column)+pascal(row-1,column-1);
      }
  }
}