forked from subhojit-mukherjee/pythoncodes
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMultiplesof3and5.py
More file actions
70 lines (63 loc) · 1.14 KB
/
Multiplesof3and5.py
File metadata and controls
70 lines (63 loc) · 1.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
'''
Created on May 6, 2015
https://www.hackerrank.com/contests/projecteuler/challenges/euler001
@author: Chocolate
'''
def sum1(n,d):
m = int(n/d);
return (d*m*(m+1)/2);
for _ in xrange(input()):
n=input();
print(sum1(n-1,3)+sum1(n-1,5)-sum1(n-1,15));
'''
def check15(num):
if num%15==0:
return 1;
else:
return 0;
for _ in xrange(input()):
n=input();
a=3;
b=5;
i=a;
j=b;
sum1=0;
count=2;
var=1;
if n<3:
print(0);
continue;
while var==1:
if (i>=n) and (j>=n):
break;
if(i<n):
sum1+=i;
i=a*count;
if(j<n):
sum1+=j;
j=b*count;
count+=1;
a=15;
i=a;
count=2;
while var==1:
if i>=n:
break;
sum1=sum1-i;
i=a*count;
count+=1;
print(sum1);
'''
'''def checkDiv(num):
if (num%3==0) or (num%5==0):
return 1;
else:
return 0;
for _ in xrange(input()):
n=input();
sum1=0;
for i in xrange(3,n,1):
if(checkDiv(i)==1):
sum1+=i;
print(sum1);
'''