Alex_H, on 02 February 2011 - 06:18 PM, said:
Refactored baagvai's code....85 characters
class C {
public static void main(String[] a) {
int s=0,n=999;
while(n-->0) { s += n%3*n%5>0?0:n; }
}
}
I had the same idea as you but the total sum is 232169 instead of 233168. When n goes into the while loop, it will be 998 instead of 999.

New Topic/Question
Reply



MultiQuote



|