Help with Go. numbers from 1 to n (n is entered from the keyboard). In each row you need to print the next number and as many “+” characters as how many divisors of this number

I need to make code like: numbers from 1 to n (n is entered from the keyboard). In each row you need to print the next number and as many “+” characters as how many divisors of this number. Example:
1+
2++
3++
4+++
5++

2 Likes

and what is the problem?

3 Likes

First, build a func that calculates all the divisors of a number. You can use modulus operator (%) to know that.

  // Gets divisors from 1 to num
   for i:=1; i <= num; i++ {
       if num % i == 0 {
          fmt.Println(i);
       }
  }
  1. Need to use a counter to get the numbers of divisors

Try them and post any further questions…

3 Likes

thx, trying.

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.