Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Go Language Go Language Overview Flow Control Loops

GoLang Counting up in 3s

Struggling to get this one right, appreciate any help

src/loops/loop.go
package loops

import "fmt"

func CountByThrees(start int, end int) {
  // YOUR CODE HERE
}

2 Answers

Steven Parker
Steven Parker
229,744 Points

It doesn't look like you've written any code yet. If you don't know how to start, you might want to watch the Loops video again. It contains an example that is very close to what you need to do for this challenge.

Thanks Steven for the help. I understand the loops and how they should look. What I'm struggling on is how I would specify the start int, and stopping at end int.

package loops

import "fmt"

func CountByThrees(start int, end int) {
  for i := start; i <= end; i+=3 {
  fm.Println(i)
  }
}

I know for i := start; i <= end; i+=3 { is definitely wrong. But maybe it will help guide where my mental struggle is :)

Steven Parker
Steven Parker
229,744 Points

Your loop looks perfectly correct. :+1: The only error I see is on the next line where you have "fm" instead of "fmt".