pascal's triangle recursion code example

Example 1: Pascal's triangle in java using recursion

// Pascal's triangle in java using recursion
import java.util.Scanner;
public class RecursionPascalTriangle 
{
   public static void display(int num)
   {
      for(int a = 0; a < num; a++)
      {
         for(int b = 0; b <= a; b++)
         {
            System.out.println(pascalTriangle(a, b) + " ");
         }
         System.out.println();
      }
   }
   public static int pascalTriangle(int a, int b)
   {
      if(b == 0 || b == a)
      {
         return 1;
      }
      else
      {
         return pascalTriangle(a - 1, b - 1) + pascalTriangle(a - 1, b);
      }
   }
   public static void main(String[] args)
   {
      Scanner sc = new Scanner(System.in);
      System.out.println("Please enter number of rows: ");
      int row = sc.nextInt();
      display(row);
      sc.close();
   }
}

Example 2: pascal's triangle python reverse function

def pascal_triangle(n):
   	trow = [1]
   	y = [0]
   	for x in range(max(n,0)):
      	print(trow)
      	trow=[l+r for l,r in zip(trow+y, y+trow)]
   	return n>=1
pascal_triangle(6)