Calculate sum of first N natural numbers Dry Run in PYTHON

Calculate sum of first N natural numbers is an interactive PYTHON dry run visualizer from the While programs section. Study the source code, then use the execution controls to follow each step, variable update, highlighted line, and console output.

This page provides a browser-based dry run with source-code highlighting, auto-scroll, voice narration controls, and execution output for learning the program step by step.

Calculate sum of first N natural numbers Program Code

# Sum of first N natural numbers
n = int(input("Enter N: "))
sum_numbers = 0
i = 1

while i <= n:
    sum_numbers += i
    i += 1

print(f"Sum of first {n} numbers = {sum_numbers}")

View the complete While programs page.

Program Console Calculate sum of first N natural numbers Topic: PYTHON Vignaankosh.com
Execution Panel
Step 0/0
Console is empty.