Menu
Coddy logo textTech

Sum And Divide

Lesson 2 of 24 in Coddy's Golang Challenges - Level 1 course.

challenge icon

Challenge

Easy

Write a function that will take two numbers, calculate the sum of all numbers between them (inclusive), and divide that sum by the sum of the two entered numbers.

 

Example:

For the numbers 4 and 10:

  1. Calculate the sum of all numbers between 4 and 10:

    4 + 5 + 6 + 7 + 8 + 9 + 10 = 49

  2. Divide this sum by the sum of the two entered numbers:

    49 / 4 + 10 

  3. The result will be:

    3.5

Try it yourself

func sumAndDivide() () {

}

All lessons in Golang Challenges - Level 1