Hacker News new | past | comments | ask | show | jobs | submit login

At the risk of the classic "no here's the fizzbuzz code" while then getting it wrong, the typical case you're trying to draw out is like the second but:

Not printing in the middle, return a string and afterwards print it.

Each step adds to the string, and if it's still empty by the end you just put the number in.

The next stages are often to add another number, then something more complex (if it's a prime number). As you do this, the concatenation version grows slowly while the first approach explodes in combinations.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: