Generate Pattern
Lesson 3 of 24 in Coddy's Golang Challenges - Level 1 course.
Challenge
EasyWrite 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
1Introduction
Introduction2Play With Numbers
Sum And DivideGenerate PatternNumber RotationEven and Divisible NumbersDiamond PatternAbundant NumberCheck a Number