You are viewing a single comment's thread. Return to all comments →
long a=(n-1)/3; long b=(n-1)/15; long c=((n-1)/5); System.out.println(3*(((a+1)*a)/2) +5*(((c+1)*c)/2)-15*(((b+1)*b)/2));
Seems like cookies are disabled on this browser, please enable them to open this website
Project Euler #1: Multiples of 3 and 5
You are viewing a single comment's thread. Return to all comments →