mirror of
https://github.com/TheAlgorithms/Python.git
synced 2024-11-24 05:21:09 +00:00
Update sol2.py
This commit is contained in:
parent
dbfc220264
commit
3562182542
|
@ -11,10 +11,10 @@ except NameError:
|
||||||
raw_input = input # Python 3
|
raw_input = input # Python 3
|
||||||
n = int(raw_input().strip())
|
n = int(raw_input().strip())
|
||||||
sum = 0
|
sum = 0
|
||||||
terms = (n-1)/3
|
terms = (n-1)//3
|
||||||
sum+= ((terms)*(6+(terms-1)*3))/2 #sum of an A.P.
|
sum+= ((terms)*(6+(terms-1)*3))//2 #sum of an A.P.
|
||||||
terms = (n-1)/5
|
terms = (n-1)//5
|
||||||
sum+= ((terms)*(10+(terms-1)*5))/2
|
sum+= ((terms)*(10+(terms-1)*5))//2
|
||||||
terms = (n-1)/15
|
terms = (n-1)//15
|
||||||
sum-= ((terms)*(30+(terms-1)*15))/2
|
sum-= ((terms)*(30+(terms-1)*15))//2
|
||||||
print(sum)
|
print(sum)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user