Problem:


Score : 200 points

Problem Statement

Let us define the FizzBuzz sequence a_1,a_2,... as follows:

If both 3 and 5 divides i, a_i=\mbox{FizzBuzz}.

If the above does not hold but 3 divides i, a_i=\mbox{Fizz}.

If none of the above holds but 5 divides i, a_i=\mbox{Buzz}.

If none of the above holds, a_i=i.

Find the sum of all numbers among the first N terms of the FizzBuzz sequence.

Constraints

1 \leq N \leq 10^6

Input

Input is given from Standard Input in the following format:

N

Output

Print the sum of all numbers among the first N terms of the FizzBuzz sequence.

Sample Input 1

15

Sample Output 1

60

The first 15 terms of the FizzBuzz sequence are:

1,2,\mbox{Fizz},4,\mbox{Buzz},\mbox{Fizz},7,8,\mbox{Fizz},\mbox{Buzz},11,\mbox{Fizz},13,14,\mbox{FizzBuzz}

Among them, numbers are 1,2,4,7,8,11,13,14, and the sum of them is 60.

Sample Input 2

1000000

Sample Output 2

266666333332

Watch out for overflow.



Sample input:
15


Sample output:
60

Submission status: Accepted

Solution code:
N = int(input())
ans = 0
for i in range(1, N+1):
    if not (i%3==0 or i%5==0):
        ans += i
print(ans)

Submission status: Accepted

Solution code:
sum=0
for i in range(1,int(input())+1):
    if i%3!=0 and i%5!=0:
        sum+=i
print(sum)

Submission status: Accepted

Solution code:
def main():
    n = int(input())

    print(sum(i for i in range(1, n + 1) if i % 3 and i % 5))


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
def main():
    N = int(input())
    s = 0
    for i in range(1, N+1):
        if i % 3 == 0 and i % 5 == 0:
            pass
        elif i % 3 == 0:
            pass
        elif i % 5 == 0:
            pass
        else:
            s += i
    print(s)
main()

Submission status: Accepted

Solution code:
n =int(input())
count =0
for i in range(1,n+1):
    if i %3 !=0:
        if i %5 !=0:
            count +=i
print(count)

Submission status: Accepted

Solution code:
A=int(input())
three=int(A/3)
five=int(A/5)
fif=int(A/15)
count=0
for i in range(A+1):
    count+=i

if A>=15:
    final=int(count-(1/2*three*(3+three*3))-(1/2*five*(5+five*5))+(1/2*fif*(15+fif*15)))
    print(final)

elif 5<=A<15:
    final=int(count-(1/2*three*(3+three*3))-(1/2*five*(5+five*5)))
    print(final)

elif 3<=A<5:
    final=int(count-(1/2*three*(3+three*3)))
    print(final)

else:
    print(count)

Submission status: Accepted

Solution code:
print(sum(i for i in range(int(input())+1) if (i%3!=0 and i%5!=0)))

Submission status: Accepted

Solution code:
total = 0
for i in range(int(input())):
  if int((i+1) % 3) != 0:
    if int((i+1) % 5) != 0:
    	total += i+1
        
print(total)

Submission status: Accepted

Solution code:
import math
from collections import defaultdict
ml=lambda:map(int,input().split())
ll=lambda:list(map(int,input().split()))
ii=lambda:int(input())
ip=lambda:input()

"""========main code==============="""

t=ii()
ans=0
for i in range(1,t+1):
    if(i%3!=0 and i%5!=0):
        ans+=i
print(ans)

Submission status: Accepted

Solution code:
import sys
from collections import Counter

sys.setrecursionlimit(10 ** 6)


def input(): return sys.stdin.readline().rstrip()


N = int(input())
print(sum(i for i in range(1, N + 1) if i % 3 != 0 and i % 5 != 0))

Submission status: Accepted

Solution code:
n = int(input())
ans = 0
for i in range(1,n+1):
    if i%3 != 0 and i%5 != 0:
        ans += i
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
sum = 0
for i in range(1, N+1):
  if i%3!=0 and i%5 != 0:
    sum += i
print(sum)

Submission status: Accepted

Solution code:
x = int(input())

digit = 0
for i in range(x):
    x = i + 1

    if x % 3 == 0 and x % 5 == 0:
        continue
    elif x % 3 == 0 and x % 5 != 0:
        continue
    elif x % 3 != 0 and x % 5 == 0:
        continue
    else:
        digit += x



print(digit)

Submission status: Accepted

Solution code:
n = int(input())
n3 = n//3
n5 = n//5
n15 = n//15
def sum(k):
    return k*(k+1)//2
ans = sum(n)+15*sum(n15)-3*sum(n3)-5*sum(n5)
print(ans)

Submission status: Accepted

Solution code:
N=int(input())

ans=0
for i in range(N+1):
    if (i%5!=0) and (i%3!=0):
        ans=ans+i
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
sum = 0
for i in range(1, N + 1):
  if i % 3 != 0 and i % 5 != 0:
    sum += i
print(sum)

Submission status: Accepted

Solution code:
N=int(input())
counter=0
for i in range(1,N+1):
    if i%3==0 or i%5==0:
        counter+=0
    else:
        counter+=i
print(counter)

Submission status: Accepted

Solution code:
n = int(input())

n15 = n // 15
n5 = n // 5
n3 = n // 3

ans = n*(n+1)//2 - 5*n5*(n5+1)//2 - 3*n3*(n3+1)//2 + 15*n15*(n15+1)//2

print(ans)

Submission status: Accepted

Solution code:
n = int(input())
ans = 0
for i in range(n + 1):
    if i % 3 != 0 and i % 5 != 0:
        ans += i
print(ans)

Submission status: Accepted

Solution code:
import numpy as np
N = int(input())

row = np.arange(1, N+1)

FizzBuzz = row[row%15==0]
Fizz = row[row%3==0]
Buzz = row[row%5==0]

print(np.sum(row) - (np.sum(Fizz) + np.sum(Buzz) - np.sum(FizzBuzz)))

Submission status: Accepted

Solution code:
def wa(n):
    return n * (n+1) // 2


N = int(input())

print(wa(N) - wa(N//3) * 3 - wa(N // 5) * 5 + wa(N // 15) * 15)

Submission status: Accepted

Solution code:
#FizzBizz
total=0
n=int(input(""))
for i in range(1,n+1):
    if i%3!=0 and i%5!=0:
        total=total+i
print(total)

Submission status: Accepted

Solution code:
N=int(input(""))
sum = 0
for x in range(1, N+1):
  if x % 3 != 0 and x % 5 != 0:
    sum = sum + x
print(sum)

Submission status: Accepted

Solution code:
n = int(input())
s = 0
for i in range(1,n+1) :
    if i%3==0 or i%5==0 :
        continue
    s += i
print(s)

Submission status: Accepted

Solution code:
n = int(input())
sum=0
for i in range(n+1):
  if((i%3!=0)&(i%5!=0)):
    sum=sum+i
print(sum)

Submission status: Accepted

Solution code:
input_num = int(input())

ans = 0

for i in range(1, input_num+1):
    if i % 3 == 0 or i % 5 == 0:
        continue
    else:
        ans += i
        
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
#A = list(map(int, input().split()))
amount = (N+1) * N // 2
three = N // 3
three = (three + 1) * 3 * three // 2 if three > 0 else 0
five = N // 5
five = (five + 1) * 5 * five // 2 if five > 0 else 0
fifteen = N // 15
fifteen = (fifteen + 1) * 15 * fifteen // 2 if fifteen > 0 else 0
print(amount-three-five+fifteen)

Submission status: Accepted

Solution code:
N=int(input())
FB=0
for i in range(N+1):
  if i%3==0 or i%5==0:
    FB+=i
    

SUM=0
for i in range(N+1):
  SUM+=i
  
Ans=SUM-FB
print(Ans)

Submission status: Accepted

Solution code:
n = int(input())
a = 0
for i in range(1,n+1):
    if not ((i%3 == 0)or (i%5 == 0)):
        a += i
print(a)

Submission status: Accepted

Solution code:
N = int(input())

ans = 0
for i in range(1, N + 1):
  if i % 3 != 0 and i % 5 != 0:
    ans += i
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
s = 0
for i in range(N+1):
  if i%3 !=0 and i%5!=0:
    s+=i
print(s)

Submission status: Accepted

Solution code:
from sys import stdin
input=lambda : stdin.readline().strip()
from math import ceil,sqrt,factorial,gcd,log
su=0
for i in range(1,int(input())+1):
	if i%3!=0 and i%5!=0:
		su+=i
print(su)

Submission status: Accepted

Solution code:
N=int(input())
m=[0]*N
for i in range(N):
    if (i+1)%3!=0 and (i+1)%5!=0:
        m[i]=i+1
print(sum(m))

Submission status: Accepted

Solution code:
def fizz_buzz_sum(N):
  not_fizz_buzz = [i for i in range(1, N+1) if (i%3 != 0) and (i%5 != 0)]
  return sum(not_fizz_buzz)

print(fizz_buzz_sum(int(input())))

Submission status: Accepted

Solution code:
N = int(input())
ans = int(N * (N + 1) / 2 - (N // 3) * (N // 3 + 1) / 2 * 3 - (N // 5) * (N // 5 + 1) / 2 * 5 + (N // 15) * (N // 15 + 1) / 2 * 15)
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
ans = 0
for i in range(N):
    if (i + 1) % 3 != 0 and (i + 1) % 5 != 0:
        ans += i + 1
print(ans)

Submission status: Accepted

Solution code:
def sum(N):
    return N * (N + 1) // 2


N = int(input())
print(sum(N) - sum(N // 3) * 3 - sum(N // 5) * 5 + sum(N // 15) * 15)

Submission status: Accepted

Solution code:
N = int(input())
i = 0
for a in range(N+1):
    if a%3 != 0 and a%5 != 0:
        i = i + a
    else:
        pass
print(i)

Submission status: Accepted

Solution code:
N = int(input())
mysum = 0
for i in range(1,N+1):
	if i%3 == 0 or i%5 == 0:
		mysum += 0
	else: 
		mysum += i
print(mysum)

Submission status: Accepted

Solution code:
n = int(input())
ans = 0
for i in range(1, n + 1):
    if not(i % 15 == 0 or i % 5 == 0 or i % 3 == 0):
        ans += i
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
count = 0
for x in range(0, N+1):
    if x%3!=0 and x%5!=0:
       count=count+x
print(count)

Submission status: Accepted

Solution code:
N = int(input())

numbers = list(range(1,N+1))
int_numbers = [int(x) for x in numbers]

#print(int_numbers)
for i in range(len(int_numbers)):
    if int_numbers[i] % 15 == 0:
        int_numbers[i] = 0
    elif int_numbers[i] % 5 == 0:
        int_numbers[i] = 0
    elif int_numbers[i] % 3 == 0:
        int_numbers[i] = 0
        
print(sum(int_numbers))

Submission status: Accepted

Solution code:
n = int(input())

s=0
for i in range(1, n+1):
  if i%3!=0 and i%5!=0:
    s+=i
    
print(s)

Submission status: Accepted

Solution code:
n = int(input())

sum = 0
for i in range(1, n + 1):
    if i % 3 != 0 and i % 5 != 0:
        sum += i
print(sum)

Submission status: Accepted

Solution code:
a = int(input())
n3 = a//3
n5 = a//5
n15 = a//15
ans = a*(a+1)//2 - 3*n3*(n3+1)//2 - 5*n5*(n5+1)//2 + 15*n15*(n15+1)//2
print(ans)

Submission status: Accepted

Solution code:
x=int(input())
sum=0
for i in range(1,x+1):
    if(i%3!=0 and i%5!=0):
        sum=sum+i
print(sum)

Submission status: Accepted

Solution code:
N = int(input())
total = 0
for i in range(1, N+1):
    if i % 3 != 0 and i % 5 != 0:
        total = total+i
print(total)

Submission status: Accepted

Solution code:
sum = 0
term = int(input())
s = "abcdefghijklmnopqrstuvwxyz"
for i in range(term+1):
    if i % 3 != 0 and i% 5 != 0:
        sum += i

print(sum)

Submission status: Accepted

Solution code:
N = int(input())
n3 = N // 3
n5 = N // 5
n15 = N // 15
sum3 = 3*n3*(n3+1)//2
sum5 = 5*n5*(n5+1)//2
sum15 = 15*n15*(n15+1)//2
print(N*(N+1)//2 - sum3 - sum5 + sum15)

Submission status: Accepted

Solution code:
n=int(input())
count=0
for i in range(1,n+1):
  if i%3==0 or i%5==0:
    continue
  else:
    count+=i
    
print(count)

Submission status: Accepted

Solution code:
N = int(input())
sum = 0
for i in range(1, N+1):
    if (i%3 != 0 and i%5 != 0):
        sum += i

print(sum)

Submission status: Accepted

Solution code:
n = int(input())
ans = 0

for i in range(n+1):
    if i%3 != 0 and i%5 != 0:
        ans += i

print(ans)

Submission status: Accepted

Solution code:
N = int(input())
num=1
ans=0
while num<=N:
    if num%3!=0 and num%5!=0: ans+=num
    num+=1
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
cnt=0
for i in range(1,N+1):
  if i%3 != 0 and i%5 !=0:
    cnt += i
print(cnt)

Submission status: Accepted

Solution code:
N=input()
N=int(N)

a=1
sum_a=0
while a<=N:
	sum_a=sum_a+a
	a=a+1

b=1
sum_b=0
while b<=N//3:
	sum_b=sum_b+b
	b=b+1
	
c=1
sum_c=0
while c<=N//5:
	sum_c=sum_c+c
	c=c+1
	
d=1
sum_d=0
while d<=N//15:
	sum_d=sum_d+d
	d=d+1
	

print(sum_a+15*sum_d-3*sum_b-5*sum_c)

Submission status: Accepted

Solution code:
n=int(input())
wa=0
for i in range(1,n+1):
    if i%3==0 or i%5==0:
        continue
    else:
        wa+=i
print(wa)

Submission status: Accepted

Solution code:
import numpy as np
a = np.arange(1, int(input()) + 1)
print(sum(a[np.logical_and(a % 3 != 0, a % 5 != 0)]))

Submission status: Accepted

Solution code:
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n = int(input())

    res = 0
    for i in range(1, n + 1):
        if i % 3 == 0 or i % 5 == 0:
            continue
        else:
            res += i

    print(res)


if __name__ == '__main__':
    resolve()

Submission status: Accepted

Solution code:
n=int(input())
count=0
for i in range(1,n+1):
    if i%3==0 or i%5==0:
        continue
    else:
        count+=i;
print(count)

Submission status: Accepted

Solution code:
n = int(input())

ans = 0
for i in range(n+1):
    if i % 3 != 0 and i % 5 != 0:
        ans += i
print(ans)

Submission status: Accepted

Solution code:
max_num = input()
num_list = [num + 1 for num in range(int(max_num)) if (num + 1) % 3 != 0 and (num + 1) % 5 != 0]
print(sum(num_list))

Submission status: Accepted

Solution code:
import sys
import numpy as np

N=int(input())
A=np.arange(N+1)
count = 0

for i in range(N+1):
    if A[i]%3 != 0 and A[i]%5 != 0 and A[i]%15 != 0:
        count = count + A[i]
print(count)

Submission status: Accepted

Solution code:
num = int(input())
fizz_buzz_sum = 0
for i in range(1, num + 1):
  if i % 3 != 0 and i % 5 != 0:
    fizz_buzz_sum += i

print(fizz_buzz_sum)

Submission status: Accepted

Solution code:
num = int(input())

n_loop, reminder = divmod(num, 15)
total = 0
i = -1
for i in range(n_loop):
	total += i *15 *  8 + sum([1, 2, 4, 7, 8, 11, 13, 14])
remaining_nums = [num for num in range(1, reminder+1) if num % 3 and num % 5]
total += sum(remaining_nums) + (i + 1) * 15 * len(remaining_nums)

print(total)

Submission status: Accepted

Solution code:
N = int(input())
sum = 0

for i in range(1 , N + 1):
    if i % 3 != 0 and i % 5 != 0:
        sum += i

print(sum)

Submission status: Accepted

Solution code:
num = int(input())
fizzBuzz = 0

while(num > 0):
  if(num % 15 == 0):
    num -= 1
    continue
  elif(num % 3 == 0):
    num -= 1
    continue
  elif(num % 5 == 0):
    num -= 1
    continue
  else:
    fizzBuzz += num
    num -= 1

print(fizzBuzz)

Submission status: Accepted

Solution code:
n = int(input())
l = []
add = 0
for i in range(1,n+1):
    if i%3 == 0 and i%5 == 0:
        l.append("fizzBuzz")
    elif i%3 == 0:
        l.append("Fizz")
    elif i%5 == 0:
        l.append("Buzz")
    else:
        l.append(i)
        add = add + i
print(add)

Submission status: Accepted

Solution code:
n = int(input())
l = [i for i in range(1, n + 1)]
nl = []

for a in l:
    if (a % 5 != 0) and (a % 3 != 0):
        nl.append(a)

print(sum(nl))

Submission status: Accepted

Solution code:
N = int(input())

sum = 0
for i in range(1, N+1):
    if i%3==0 and i%5==0:
        continue
    elif i%3==0:
        continue
    elif i%5==0:
        continue
    sum += i
print(sum)

Submission status: Accepted

Solution code:
N = int(input())
total = 0
for i in range(1, N+1):
    if i % 3 != 0 and i % 5 != 0:
        total += i
print(total)

Submission status: Accepted

Solution code:
n = int(input())
sum = 0
for i in range(1,n+1):
  if i % 3 != 0 and i%5 != 0:
  	sum += i
  
print(sum)

Submission status: Accepted

Solution code:
n=int(input())
s=0
for i in range(1,n+1):
  if(i%3!=0):
    if(i%5):
      s+=i
    
print(s)

Submission status: Accepted

Solution code:
n=int(input())
sum=0
for i in range(1,n+1):
  if not (i%3==0 or i%5==0):
    sum=sum+i
print(sum)

Submission status: Accepted

Solution code:
n = int(input())
s = 0

for a in range(1, n+1):
  if a % 3 != 0 and a % 5 != 0:
      s += a

print(s)

Submission status: Accepted

Solution code:
n = int(input())
s = 0
for i in range(n + 1):
    if i % 3 != 0 and i % 5 != 0:
        s += i
print(s)

Submission status: Accepted

Solution code:
N = int(input())
wa = 0
for i in range (1,N+1):
  if ((i % 3 == 0) or (i % 5 == 0)) == False:
    wa += i
print(wa)

Submission status: Accepted

Solution code:
n = int(input())
a = 0
for i in range(1, n+1):
    if (i % 3 != 0) and (i % 5 != 0):
        a += i

print(a)

Submission status: Accepted

Solution code:
N=int(input())

total=0

for i in range(1,N+1):
  if i%3==0 or i%5==0:
    pass
  else:
    total +=i

print(total)

Submission status: Accepted

Solution code:
N = int(input())

print(N*(N+1)//2 - 3*(N//3*(N//3+1)//2) - 5*(N//5*(N//5+1)//2) + 15*(N//15*(N//15+1)//2))

Submission status: Accepted

Solution code:
N = int(input())

l = [i for i in range(N+1) if i % 3 != 0 and i % 5 != 0]
print(sum(l))

Submission status: Accepted

Solution code:
n = int(input())

cnt = 0

for i in range(n+1):
    if i % 3 == 0 or i % 5 == 0:
        continue
    else:
        cnt += i

print(cnt)

Submission status: Accepted

Solution code:
N = int(input())
#3で割り切れるFizzの和
sho3 = N // 3
wa3 = 3 * sho3 * (sho3 + 1) / 2

#Buzzの和
sho5 = N // 5
wa5 = 5 * sho5 * (sho5 + 1) / 2

#FizzBuzzの和
sho15 = N // 15
wa15 = 15 * sho15 * (sho15 + 1) / 2

wa = N * (N + 1) / 2
sum =int(wa - (wa3 + wa5 - wa15))
print(sum)

Submission status: Accepted

Solution code:
N=input()
a=0
i=1
while i<=int(N):
    if i%3==0:
        j = 0
    elif i%5==0:
        j = 0
    else:
        j=i
    a += j
    i+=1
print(a)

Submission status: Accepted

Solution code:
N = int(input())
a = 0
for i in range(1,N+1):
    if i % 5 == 0 or i % 3 == 0:
        a = a
    else:
        a = a + i
print(a)

Submission status: Accepted

Solution code:
n = int(input())
sum_c = 0

for i in range(1, n + 1):
    if (i %3 != 0) and (i % 5 != 0):
        #print(i)
        sum_c += i

print(sum_c)

Submission status: Accepted

Solution code:
N=int(input())
N3=N//3
N5=N//5
N15=N//15
def s(x):
    return x*(x+1)//2
print(s(N)-3*s(N3)-5*s(N5)+15*s(N15))

Submission status: Accepted

Solution code:
N = input()

summation = 0
for i in range(int(N) + 1):
    if i % 3 == 0 and i % 5 == 0:
        continue
    elif i % 3 == 0:
        continue
    elif i % 5 == 0:
        continue
    else:
        summation += i

print(summation)

Submission status: Accepted

Solution code:
n = int(input())

ans = 0

for i in range(n+1):
    if i%3 == 0 or i%5 == 0:
        pass
    else:
        ans += i

print(ans)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3

import sys
# import math
# import re                                    # re.compile(pattern) => ptn obj; p.search(s), p.match(s), p.finditer(s) => match obj; p.sub(after, s)
# from collections import deque                # deque class. deque(L): dq.append(x), dq.appendleft(x), dq.pop(), dq.popleft(), dq.rotate()
# from collections import defaultdict          # subclass of dict. defaultdict(facroty)
# from collections import Counter              # subclass of dict. Counter(iter): c.elements(), c.most_common(n), c.subtract(iter)
# from heapq import heapify, heappush, heappop # built-in list. heapify(L) changes list in-place to min-heap in O(n), heappush(heapL, x) and heappop(heapL) in O(lgn).
# from heapq import nlargest, nsmallest        # nlargest(n, iter[, key]) returns k-largest-list in O(n+klgn).
# from itertools import count, cycle, repeat   # count(start[,step]), cycle(iter), repeat(elm[,n])
# from itertools import groupby                # [(k, list(g)) for k, g in groupby('000112')] returns [('0',['0','0','0']), ('1',['1','1']), ('2',['2'])]
# from itertools import starmap                # starmap(pow, [[2,5], [3,2]]) returns [32, 9]
# from itertools import product                # product(iter, repeat=n)
# from itertools import accumulate             # accumulate(iter[, f])
# from functools import reduce                 # reduce(f, iter[, init])
# from functools import lru_cache              # @lrucache ...arguments of functions should be able to be keys of dict
# from bisect import bisect_left, bisect_right # bisect_left(a, x, lo=0, hi=len(a)) returns i such that all(val<x for val in a[lo:i]) and all(val>-=x for val in a[i:hi]).
# from copy import deepcopy                    # to copy multi-dimentional matrix without reference
# from fractions import gcd                    # for Python 3.4


def main():
    mod = 1000000007                  # 10^9+7
    inf = float('inf')
    sys.setrecursionlimit(10**6)    # 1000 -> 1000000
    def input(): return sys.stdin.readline().rstrip()
    def ii():  return int(input())
    def mi():  return map(int, input().split())
    def mi_0(): return map(lambda x: int(x)-1, input().split())
    def lmi(): return list(map(int, input().split()))
    def lmi_0(): return list(map(lambda x: int(x)-1, input().split()))
    def li():  return list(input())
    
    
    n = ii()
    ans = 0
    for i in range(1, n+1):
        if i % 3 != 0 and i % 5 != 0:
            ans += i
    print(ans)

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
n = int(input())
ans = 0
for i in range(1,n+1):
    if (i%5==0) and (i%3==0):
        pass
    elif i%5==0:
        pass
    elif i%3==0:
        pass
    else:
        ans += i
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
ans = 0
for i in range(1, N + 1):
    if i % 5 > 0 and i % 3 > 0:
        ans += i
print(ans)

Submission status: Accepted

Solution code:
N = int(input())

ans = 0

for i in range(1,N+1):
    if i%3 != 0 and i%5 != 0:
            ans += i

print(ans)

Submission status: Accepted

Solution code:
N = int(input())
a_i = 0
for i in range(1, N+1):
    if i % 3 != 0:
        if i % 5 != 0:
            a_i += i
print(a_i)

Submission status: Accepted

Solution code:
N=int(input())

ans = 0
for i in range(1,N+1):
  if i%3 != 0 and i%5 != 0:
    ans += i
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
a = []
for i in range(1,N+1):
  if(i%3==0 and i%5==0):
    pass
  elif(i%3==0):
    pass
  elif(i%5==0):
    pass
  else:
    a.append(i)
print(sum(a))

Submission status: Accepted

Solution code:
n=int(input())
l=[]
for i in range(1,n+1):
    if i%3==0 or i%5==0:continue
    l.append(i)
print(sum(l))

Submission status: Accepted

Solution code:
a = int(input())
list1 = []
list2 = []
for i in range(a):
	list1.append(i+1)
	i+=1
for x in list1:
	if not ((x%3 == 0) or (x%5==0)):
		list2.append(x)
print(sum(list2))

Submission status: Accepted

Solution code:
n = int(input())
x = 0

for i in range(1,n+1):
    if i%5!=0 and i%3!=0:
        x += i
print(x)

Submission status: Accepted

Solution code:
N=int(input())
N3=N//3
N5=N//5
N15=N//15
def s(x):
  return x*(x+1)//2
print(s(N)-3*s(N3)-5*s(N5)+15*s(N15))

Submission status: Accepted

Solution code:
from __future__ import division, print_function
import os
import sys
from io import BytesIO, IOBase

if sys.version_info[0] < 3:from __builtin__ import xrange as range;from future_builtins import ascii, filter, hex, map, oct, zip 

BUFSIZE = 8192;
class FastIO(IOBase):
    newlines = 0
 
    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None
 
    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()
 
    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()
 
    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)
 
 
class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")
 
 
def print(*args, **kwargs):
    """Prints the values to a stream, or to sys.stdout by default."""
    sep, file = kwargs.pop("sep", " "), kwargs.pop("file", sys.stdout)
    at_start = True
    for x in args:
        if not at_start:
            file.write(sep)
        file.write(str(x))
        at_start = False
    file.write(kwargs.pop("end", "\n"))
    if kwargs.pop("flush", False):
        file.flush()


if sys.version_info[0] < 3: 
    sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)
else:
    sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)

input = lambda: sys.stdin.readline().rstrip("\r\n");ii = lambda: int(input());ll = lambda: list(map(int , input().split()));vv = lambda: map(int , input().split());pr = print
pl = lambda l: pr(" ".join(list(map(str,l))))
import math
def fun(n):
    tot = n * (n+1)
    tot//=2
    return tot

n = ii()
print(fun(n) - 3*fun(n//3) -5*fun(n//5) + 15*fun(n//15))

Submission status: Accepted

Solution code:
N = int(input())
total = 0
for i in range(1, N + 1):
  if i % 3 != 0 and i % 5 != 0:
    total += i
print(total)

Submission status: Accepted

Solution code:
n = int(input())
l = 0
for i in range(1,n+1):
	if i%3!=0 and i%5!=0:
		l+=i
print(l)

Submission status: Accepted

Solution code:
N = int(input())

ans = 0
for i in range(N+1):
  if i % 3 != 0 and i % 5 != 0:
    ans += i
    
print(ans)

Submission status: Accepted

Solution code:
n=int(input())
s=0
for i in range(1,n+1):
    if i%3!=0 and i%5!=0:
        s+=i
print(s)

Submission status: Accepted

Solution code:
N = int(input())
s = 0
for n in range(1, N + 1):
    if n % 3 == 0:
        continue
    if n % 5 == 0:
        continue
    s = s + n

print(s)

Submission status: Accepted

Solution code:
def could_divide(num):
  return (num%3==0 or num%5==0)
n=int(input())
answer=0
for i in range(1,n+1):
  if(not could_divide(i)):
    answer+=i
print(answer)

Submission status: Accepted

Solution code:
N = int(input())

sum = 0
for i in range(1, N+1):
    if i % 3 != 0 and i % 5 != 0:
        sum += i

print(sum)

Submission status: Accepted

Solution code:
from sys import stdin
N = int(stdin.readline().rstrip())
print(sum([i for i in range(1, N+1) if not i % 3 == 0 and not i % 5 == 0]))

Submission status: Accepted

Solution code:
# coding: utf-8

import sys
import math
import collections
import itertools
INF = 10 ** 13
MOD = 10 ** 9 + 7
def input() : return sys.stdin.readline().strip()
def lcm(x, y) : return (x * y) // math.gcd(x, y)
def I() : return int(input())
def LI() : return [int(x) for x in input().split()]
def RI(N) : return [int(input()) for _ in range(N)]
def LRI(N) : return [[int(x) for x in input().split()] for _ in range(N)]
def LS() : return input().split()
def RS(N) : return [input() for _ in range(N)]
def LRS(N) : return [input().split() for _ in range(N)]
def PL(L) : print(*L, sep="\n")
def YesNo(B) : print("Yes" if B else "No")
def YESNO(B) : print("YES" if B else "NO")

N = I()
 
ans = 0
for i in range(1, N+1):
    if i % 3 == 0 or i % 5 == 0:
        continue
    else:
        ans += i
 
print(ans)

Submission status: Accepted

Solution code:
N = int(input())

n3 = 0
n5 = 0
n15 = 0


for i in range(N // 3):
  n3 += 3 * (i+1)

for i in range(N // 5):
  n5 += 5 * (i+1)

for i in range(N // 15):
  n15 += 15 * (i+1)
  
print(N * (N + 1) // 2 - n3 - n5 + n15)

Submission status: Accepted

Solution code:
n = int(input())
f = sum([3*(i+1) for i in range(n//3)])
b = sum([5*(i+1) for i in range(n//5)])
fb = sum([15*(i+1) for i in range(n//15)])
print(n*(n+1)//2 - f - b + fb)

Submission status: Accepted

Solution code:
n=int(input())
total=n*(n+1)//2
a=n//15
b=n//3
c=n//5

fb=15*a*(a+1)//2
f=3*b*(b+1)//2
b=5*c*(c+1)//2

print(total-f-b+fb)

Submission status: Accepted

Solution code:
n = int(input()) + 1
answar = 0

for i in range(1,n):
    if (i%3!=0)and(i%5!=0):
        answar += i

print(answar)

Submission status: Accepted

Solution code:
n = int(input())

ans=0
for i in range(1,n+1):
    if i%3!=0 and i%5!=0:
        ans+=i
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
ans = 0
for i in range(1, n + 1):
    if i % 3 and i % 5:
        ans = ans + i
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
num = 1
sum = 0
while num <= n:
  mod=num%3
  if(mod==0):
    num += 1
    continue
  mod=num%5
  if(mod==0):
    num += 1
    continue
  sum += num
  num += 1
print(sum)

Submission status: Accepted

Solution code:
n = int(input())
fizz_sum = 0

for i in range(1, n + 1):
    if i % 3 != 0 and i % 5 != 0:
        fizz_sum += i
print(fizz_sum)

Submission status: Accepted

Solution code:
n = int(input())

a = []
for i in range(n + 1):
  if i % 3 != 0 and i % 5 != 0:
    a.append(i)

print(sum(a))

Submission status: Accepted

Solution code:
N = int(input())
F = 0
B = 0
X = 0
S = 0
for i in range (N+1):
    if i%3==0:
        F = F + i
for j in range (N+1):
    if j%5==0:
        B = B + j
for k in range (N+1):
    if k%15==0:
        X = X + k
for l in range(N+1):
    S = S + l
print(S-F-B+X)

Submission status: Accepted

Solution code:
def main():
    n = int(input())
    ans = 0
    for i in range(1,n+1):
        if i % 5!=0 and i % 3!=0:
            ans += i
    print(ans)

if __name__== "__main__":
    main()

Submission status: Accepted

Solution code:
n = int(input())

row=n//15
total=row*row*60
for i in range(1+row*15,n+1):
  if i%3 != 0:
    if i%5 != 0:
      total+=i
print(total)

Submission status: Accepted

Solution code:
a = int(input())
result = 0
for i in range(1,a+1,1):
    if i%3!=0 and i%5!=0:
        result += i
print(result)

Submission status: Accepted

Solution code:
a = int(input())
s = 0
for num in range(1,a+1):
  if num % 3 != 0 and num % 5 != 0:
    s += num
print (s)

Submission status: Accepted

Solution code:
N = int(input())
non_fizz_buzz = [x for x in range(1,N+1) if x%3 !=0 and x%5 != 0] 
print(sum(non_fizz_buzz))

Submission status: Accepted

Solution code:
N = int(input())
print(sum(x for x in range(1, N+1) if x % 3 != 0 and x % 5 != 0))

Submission status: Accepted

Solution code:
N = int(input())
sum = 0

for i in range(N):
    sum += i+1

for i in range(N+1):
    if i%3 == 0 or i%5 == 0:
        sum += -(i)

print(sum)

Submission status: Accepted

Solution code:
a=int(input())
ans=0

for i in range(1,a+1):
    if i%3!=0 and i%5!=0:
        ans+=i
        
print(ans)

Submission status: Accepted

Solution code:
N = int(input())

ans = 0
for i in range(1, N + 1):
    if i % 3 != 0 and i % 5 != 0:
       ans += i

print(ans)

Submission status: Accepted

Solution code:
N = int(input())

sum = 0
for i in range(1, N + 1):
    if i % 3 == 0 or i % 5 == 0:
        continue
    else:
        sum += i

print(sum)

Submission status: Accepted

Solution code:
n = int(input())

def sig(n):
  return int(n*(n+1)*0.5)

ans = sig(n) - 3*sig(n//3) - 5*sig(n//5) + 15*sig(n//15)

print(ans)

Submission status: Accepted

Solution code:
def FizzBuzzSum():
  N = int(input())
  sum=0
  for i in range(N+1):
    if i%3!=0 and i%5!=0:
      sum=sum+i
  return sum
print(FizzBuzzSum())

Submission status: Accepted

Solution code:
N = int(input())
num_list = [i+1 for i in range(N) if (i+1)%3 != 0 and (i+1)%5 != 0]
print(sum(num_list))

Submission status: Accepted

Solution code:
A=int(input())

res=0
k=0
for i in range(A):
  if (i+1) % 3 == 0:
    k=0
  elif (i+1) % 5 == 0:
    k=0
  else:
    res+= (i+1)
    
print(res)

Submission status: Accepted

Solution code:
num=int(input())

sum=0
for i in range(num+1):
    if i%3!=0 and i%5!=0:
        sum=sum+i

print(sum)