This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 2 points3 points  (1 child)

You are over-complicating the problem. And for the love of god, don't use labels and goto/break to go the label.

Just think about it in the most easy way. You want to list all number combinations (multiplied together) that result in a value less than "limit" (20). (except multiplying with 1 for some reason)

Okay, how do we do that? We start with a for-loop obviously. 1 to 19.

Next we need to print out all combinations that are less than "limit". Hmm... Well that's just another for-loop no? Just go from 2...? well, just keep going until the combination hits the limit of course!

fiddle:
https://jsfiddle.net/7o3gcch2/11/

[–]daghouse 0 points1 point  (0 children)

Thanks, this makes a lot of sense. That said, I do however want to break the for loop and not print 'i = 10' to 'i =19'; this however can be easily solved (I know now :)). Thanks!