Loading...

The Additive Chain

A easy Python interview practice problem on DataDriven. Write and execute real python code with instant grading.

Domain
Python
Difficulty
easy
Seniority
junior, mid

Problem

A well-known integer sequence is used in nature, finance, and algorithms. Write a function that generates the first n terms of this sequence using only iteration, not recursion. The sequence starts with 0 and 1, and each subsequent term is the sum of the two before it. Return the terms as a list.

Practice This Problem

Solve this Python problem with real code execution. DataDriven runs your Python code in a sandboxed Docker environment and grades it instantly.