About 57,200 results
Open links in new tab
  1. Pascal's Triangle for Python - Stack Overflow

    Jun 7, 2014 · Explanation of Pascal's triangle: This is the formula for "n choose k" (i.e. how many different ways (disregarding order), from an ordered list of n items, can we choose k items):

  2. recursion - Python recursive Pascal's triangle - Stack Overflow

    After completing an assignment to create Pascal's triangle using an iterative function, I have attempted to recreate it using a recursive function. I have gotten to the point where I can get it …

  3. python - Pascal's Triangle with a List - Stack Overflow

    Apr 3, 2014 · def pascal_triangle(height): if height < 0 : return # height = 0 T = [[1]] # loop for the next r = [1:height+1] for R in range(1, height + 2): # c == 0 N = [1] # caculate [1:r) (exclude r …

  4. Pascal's triangle in Python - Stack Overflow

    I'm making a Pascal's triangle and I can't figure out why this code isn't working. It prints out something like this: [] [1] [1, 2] [1, 3, 3] [1, 4, 6, 4] [1, 5, 10, 10, 5] [1, 6, 15, 20, 15, 6] [1...

  5. python - Pascal's Triangle Generator - Code Review Stack Exchange

    Aug 30, 2022 · Pascal's triangle is a simple and effective way to expand a set of brackets in the form (a + b)ⁿ. In my code the user is asked an input for what order (n) they want and it outputs …

  6. How to optimize printing Pascal's Triangle in Python?

    Jul 23, 2023 · I just want to add that I have modified the code to completely eliminate duplicate calculations. I observed that, if the tip of Pascal's triangle has a row index of 0, then all …

  7. python - Pascal's triangle - Recursion - Code Review Stack Exchange

    Jan 5, 2010 · Pascal’s triangle is a useful recursive definition that tells us the coefficients in the expansion of the polynomial (x + a)^n. Each element in the triangle has a coordinate, given by …

  8. Code-golf: generate pascal's triangle - Stack Overflow

    Generate a list of lists (or print, I don't mind) a Pascal's Triangle of size N with the least lines of code possible! Here goes my attempt (118 characters in python 2.6 using a trick): c,z,k=loc...

  9. Print Pascal's triangle in Python properly - Stack Overflow

    Dec 22, 2020 · You could simply just modify your existing code with 2 modifications - Before each line, add (n-line) spaces Center align each of the 1 or 2 digit numbers into a 4 alphabet space …

  10. Pascal's Triangle Generator in Python - Code Review Stack Exchange

    Jan 17, 2019 · pascal_next()combines both double_chunker() and chunk_adder() to, when given one row in Pascal's triangle, determine the next row in the triangle. pascal_triangle() iteratively …

Refresh