Add Sum

4.6

5 votes
Problem

Gourav is intereseted in finding the sum of numbers which are multiples of either 2,3 or 5 below some natural number N. If we take N=20, then numbers will be 2,3,4,5,6,8,9,10,12,14,15,16,18. Hence sum of these numbers is 122 and so is the answer.

Input Format

First line contains T that denotes the number of test cases. This is followed by T lines, each containing an integer, N .

Constraints 1 ≤ T ≤ 10^5 1 ≤ N ≤ 10^9

Output Format

For each test case, print an integer that denotes the sum of all the multiples of 2 or 3 or 5 below  N.

Time Limit: 5
Memory Limit: 256
Source Limit:
Editor Image

?