You are viewing a single comment's thread. Return to all comments →
Using AP Time Complexity: O(1)
long long sumAP(long long n, long long d) { n /= d; return (n) * (1 + n) * d / 2; } long long sumMultiples(long long n) { n--; return sumAP(n, 3) + sumAP(n, 5) - sumAP(n, 15); }
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 →
Using AP Time Complexity: O(1)