Phase 3 - Level 3: Pattern Recursion
Print patterns using recursion.
10 programs · open one, then the next
Start with Print Line of N Stars Recursively- 01Print Line of N Stars RecursivelyIntermediatePrint n stars in a line using recursion.Open example →pydef print_stars(n): # Base case if n == 0: return
- 02Print Square of Stars RecursivelyIntermediatePrint square pattern using recursion.Open example →pydef print_stars(n): if n == 0: return print("*", end="")
- 03Print Triangle (Top-Down) RecursivelyIntermediatePrint right triangle recursively.Open example →pydef print_stars(n): if n == 0: return print("*", end="")
- 04Print Triangle (Bottom-Up) RecursivelyIntermediatePrint inverted triangle recursively.Open example →pydef print_stars(n): if n == 0: return print("*", end="")
- 05Number Patterns RecursivelyIntermediatePrint number pattern using recursion.Open example →pydef print_numbers(n, current=1): # Base case if current > n: return
- 06Print Reverse Triangle RecursivelyIntermediatePrint reverse triangle pattern recursively.Open example →pydef print_stars(n): if n == 0: return print("*", end="")
- 07Multiplication Table RecursivelyIntermediatePrint multiplication table using recursion.Open example →pydef print_table_row(n, multiplier=1): # Base case if multiplier > 10: return
- 08Increasing + Decreasing in One FunctionAdvancedPrint numbers increasing then decreasing recursively.Open example →pydef print_inc_dec(n, current=1): # Base case if current > n: return
- 09Sum Series with Steps RecursivelyAdvancedCalculate sum of series with steps recursively.Open example →pydef sum_series(n, step=1): # Base case if n <= 0: return 0
- 10Character Patterns RecursivelyAdvancedPrint character patterns (A, AB, ABC...) recursively.Open example →pydef print_chars(n, current=0): # Base case if current >= n: return