Menu
Coddy logo textTech

Sum of 1 to n

Lesson 4 of 20 in Coddy's Beginner Challenges - Practice Basic Concepts course.

challenge icon

Challenge

Easy

Write a function named sum that gets a number n and returns the sum of the numbers from 1 to n.

Bonus - Make it a recursive function!

Try it yourself

int sum(int n) {
    // Write code here
}

All lessons in Beginner Challenges - Practice Basic Concepts