The first solution here is better anyway because then you don't have to duplicate the algorithm.
No, lines 11-13 are just to check my output, so I won't be duplicating anything. The second solution should be better because it doesn't use an unnecessary variable. Thanks again anyways.
@ne555: It's Euler problem 301. I can think of a much faster way to get the answer, but this was very easy and it runs in just under a second.
Without regard to the problem you are trying to solve, if int is 32 bits, the expression (3*i) on line 9 and 11 will overflow for larger values of i. Perhaps you need to use unsigned long. Or perhaps I'm missing something.