Part of the series

Several example codes

~1 min read • Updated Oct 12, 2025

Program Overview

This Python program displays the first 15 terms of a recursive sequence defined as:
F(1) = 2
F(n) = n × F(n - 1) for n > 1
It behaves like a factorial sequence but starts from 2 instead of 1.


Python Code:


def F(n: int) -> int:
    if n == 1:
        return 2
    return n * F(n - 1)

# Display first 15 terms
print("First 15 terms of the sequence:")
for i in range(1, 16):
    print(f"F({i}) = {F(i)}")

Sample Output:


F(1) = 2  
F(2) = 4  
F(3) = 12  
F(4) = 48  
F(5) = 240  
...

Written & researched by Dr. Shahin Siami