Menu
Coddy logo textTech

Even and Divisible Numbers

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

challenge icon

Challenge

Easy

Write a program that generates a list of all the numbers below a given limit x.

Write a function that takes an integer x as input and generates a list of numbers that are either even or divisible by 6, up to but not including x. The generated list should be stored in a slice, printed to the console, and the sum of the numbers generated should also be printed.

For example, if the input is 10, the output should be: [2 4 6 8] 20.

Try it yourself

import "fmt"
func divisibleNumbers(x int) {

}

All lessons in Golang Challenges - Level 1