Phase 6 - Category 4: Mathematical Combinations
Combine mathematical concepts with programming logic.
10 programs · open one, then the next
Start with Sum of Squares- 01Sum of SquaresIntermediateCalculate sum of squares 1² + 2² + ... + n².Open example →py# Take n n = int(input("Enter n: ")) # Calculate sum of squares
- 02Sum of CubesIntermediateCalculate sum of cubes 1³ + 2³ + ... + n³.Open example →py# Take n n = int(input("Enter n: ")) # Calculate sum of cubes
- 03Alternating SumIntermediateCalculate 1 - 2 + 3 - 4 + ... ± n.Open example →py# Take n n = int(input("Enter n: ")) # Calculate alternating sum
- 04Harmonic Series SumIntermediateCalculate 1 + 1/2 + 1/3 + ... + 1/n.Open example →py# Take n n = int(input("Enter n: ")) # Calculate harmonic sum
- 05Geometric Series SumIntermediateCalculate a + ar + ar² + ... + arⁿ.Open example →py# Take inputs a = float(input("Enter first term (a): ")) r = float(input("Enter common ratio (r): ")) n = int(input("Enter number of terms (n): "))
- 06Print Nth Row of Pascal TriangleAdvancedPrint nth row of Pascal triangle.Open example →py# Helper function def ncr(n, r): if r == 0 or r == n: return 1
- 07Catalan NumbersAdvancedGenerate first n Catalan numbers.Open example →py# Helper function def catalan(n): if n == 0: return 1
- 08Tribonacci SeriesIntermediateGenerate Tribonacci series (each term is sum of previous three).Open example →py# Take n n = int(input("Enter number of terms: ")) # Generate Tribonacci
- 09Lucas SeriesIntermediateGenerate Lucas series (2, 1, 3, 4, 7, ...).Open example →py# Take n n = int(input("Enter number of terms: ")) # Generate Lucas series
- 10Pell SeriesAdvancedGenerate Pell series (0, 1, 2, 5, 12, ...).Open example →py# Take n n = int(input("Enter number of terms: ")) # Generate Pell series