You are viewing a single comment's thread. Return to all comments →
import math import os import random import re import sys
def res(x,n): q = (n-1)//x return x*q*(q+1)//2
if name == 'main': t = int(input().strip())
for t_itr in range(t): n = int(input().strip()) sol = res(3,n)+res(5,n)-res(15,n) print(sol)
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 →
import math import os import random import re import sys
def res(x,n): q = (n-1)//x return x*q*(q+1)//2
if name == 'main': t = int(input().strip())