Pascal's Triangle Format

前端 未结 8 1888
长发绾君心
长发绾君心 2020-12-03 08:38

The assignment is to create Pascal\'s Triangle without using arrays. I have the method that produces the values for the triangle below. The method accepts an integer for the

8条回答
  •  广开言路
    2020-12-03 08:48

    public static long pascalTriangle(int r, int k)
    {
        if(r == 1 || k <= 1 || k >= r) return 1L;
        return pascalTriangle(r-1, k-1) + pascalTriangle(r-1, k);
    }
    

    This method allows you to find the kth value of rth row.

提交回复
热议问题