Menu
Coddy logo textTech

Generate Pattern

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

challenge icon

Challenge

Easy

Write a function that takes a number n and returns an output like this:

The generatePattern function takes an integer n as input. It first checks if n is greater than 10, and if so, it prints an error message "The number should be less than 10". If n is less than 10, it generates and prints the following pattern:

Example:

For the number 8, the output will be:

12345678
1234567
123456
12345
1234
123
12
1

 

Try it yourself

import "fmt"

func generatePattern( ) {
 
}

All lessons in Golang Challenges - Level 1