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:
import math
import string
import collections
from collections import Counter
from collections import deque
import sys
sys.setrecursionlimit(2*10**5)
INF = 2**60


def readints():
    return list(map(int, input().split()))


def nCr(n, r):
    return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))


def has_duplicates2(seq):
    seen = []
    for item in seq:
        if not(item in seen):
            seen.append(item)
    return len(seq) != len(seen)


def divisor(n):
    divisor = []
    for i in range(1, n+1):
        if n % i == 0:
            divisor.append(i)
    return divisor


# coordinates
dx = [-1, -1, -1, 0, 0, 1, 1, 1]
dy = [-1, 0, 1, -1, 1, -1, 0, 1]


N = int(input())
a = []
ans = []
for i in range(1, N+1):
    a.append(i)
# print(a)
for i in range(len(a)):

    if a[i] % 3 != 0 and a[i] % 5 != 0 and a[i] % 15 != 0:
        ans.append(a[i])
    if a[i] % 15 == 0:
        ans.append('FizzBuzz')
    if a[i] % 3 == 0:
        ans.append('Fizz')

    if a[i] % 5 == 0:
        ans.append('Buzz')


# print(ans)
sum = 0
for i in range(len(ans)):
    if ans[i] != 'FizzBuzz' and ans[i] != 'Fizz' and ans[i] != 'Buzz':
        sum += ans[i]
print(sum)

Submission status: Accepted

Solution code:
N = int(input())

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

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())
count = 0

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

print(count)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import numpy as np
x = int(input())
a = np.arange(14)+1

a = np.where((a%3)*(a%5)<1, 0, a)

b = sum(a>0)
q = x//15
print(q*60+ b*15*q*(q-1)//2+  + sum(a[:x%15]) + 15*q*sum(a[:x%15] > 0))

Submission status: Accepted

Solution code:
N = int(input())
num = [i for i in range(1,N+1) if i % 3 == 0 or i % 5 == 0]
print(sum(range(1,N+1))-sum(num))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

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

    if flag == 0:
        s += i

print(s)

Submission status: Accepted

Solution code:
print(sum(filter(lambda x : not(x%3 == 0 or x%5 == 0),range(1,int(input())+1))))

Submission status: Accepted

Solution code:
#入力:N(int:整数)
def input1():
	return int(input())

#入力:N,M(int:整数)
def input2():
	return map(int,input().split())

#入力:[n1,n2,...nk](int:整数配列)
def input_array():
	return list(map(int,input().split()))




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

Submission status: Accepted

Solution code:
N = int(input())

count = 0

for i in range(1,N+1):
    if not ((i%3==0) or (i%5==0)):
        count += i


print(count)

Submission status: Accepted

Solution code:
N=int(input())
S=N//15
P=[1,2,4,7,8,11,13,14]
P2=[3,5,6,9,10,12]
Q=0
D=0
if S==0:
    for i in range(1,N+1):
        if i in P2:
            continue
        else:
            D=D+i
else:
    T=S-1
    D=(60+60+15*T*8)*S//2
    N1=N-15*S
    for i in range(1,N1+1):
        if i in P2:
            continue
        else:
            D=D+i+15*S

print(D)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
num = int(input())
li = [i for i in range(1, num +1)]
oli = [i for i in li if i % 3 == 0 or i % 5 == 0]
print(sum(li) - sum(oli))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

# S = input()
# N, M = map(int, input().split())
# nums = list(map(int, input().split()))
# nums_2d = [list(map(int, input().split())) for _ in range(N)]


def main():

    N = int(input())

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

        total += i

    print(total)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n = int(input())

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

print(cnt)

Submission status: Accepted

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

Submission status: Accepted

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

        ans+=0
    else:
        ans+=i
print(ans)

Submission status: Accepted

Solution code:
a=int(input())

def sum30():
  return (1+2+4+7+8+11+13+14+16+17+19+22+23+26+28+29)

def sumx(x):
  ret = 0
  if(x ==0):
    return ret
  
  for j in range(1,x+1):
    if(j%3 != 0 and j%5 != 0):
      ret+=j
  return ret

def numx(x):
  ret = 0
  if(x ==0):
    return ret
  
  for j in range(1,x+1):
    if(j%3 != 0 and j%5 != 0):
      ret+=1
  return ret
sum=0

i=1
#if()
#sum+=temp*sum30()+sumx(a%30)
while(a > 0):
  if(a >= 30):
    temp=(i-1)*30*16+sum30()
    #print(temp)
    sum+=temp
  else:
    sum+=(i-1)*30*numx(a)+sumx(a)
  i+=1
  a-=30
#while(temp > 0):
#  sum+= temp*sum30()
#  temp-=1

    
print(sum)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=int(input())

cnt=n//15
r=n%15

ans=cnt*60
for i in range(cnt):
    ans+=15*8*i
tmp=0
for i in range(r+1):
    if i%3!=0 and i%5!=0:
        tmp+=i + cnt*15
print(tmp+ans)

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:
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())

zenbu = n * (n + 1) / 2

A = (sum(i for i in range(1, n + 1) if i % 3 == 0))
B = (sum(i for i in range(1, n + 1) if i % 5 == 0))
C = (sum(i for i in range(1, n + 1) if i % 15 == 0))

D = zenbu - A - B + C

print(int(D))

Submission status: Accepted

Solution code:
N = int(input())
count_list = []
for i in range(N + 1):
    if i % 15 == 0:
        count_list.append('FizzBuzz')
    elif i % 3 == 0:
        count_list.append('Fizz')
    elif i % 5 == 0:
        count_list.append('Buzz')
    else:
        count_list.append(i)
int_list = []
for i in count_list:
    try:
        int_list.append(int(i))
    except:
        pass
print(sum(int_list))

Submission status: Accepted

Solution code:
input=int(input())

output=0
a=0
for i in range(input+1):
    if i%3==0:
        a=1
    elif i%5==0:
        a=2
    else:
        output=output+i
print(output)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import sys
from decimal import *
input = sys.stdin.readline


def main():
    n = int(input())
    result = Decimal(0)
    for i in range(1, n + 1):
        if not i % 3 == 0 and not i % 5 == 0:
            result += Decimal(i)

    print(result)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math
num = int(input())
syou = math.floor(num/15)
amari = num % 15
sum = 0

list = [1,2,0,4,0,0,7,8,0,0,11,0,13,14,0]
if syou >=1:
    for x in range(syou):
        sum += 60 + 120 * x


    for i in range(amari):
        if list[i] == 0:
            None
        else:
            sum += list[i] + 15 * (syou)

    print(sum)

else:
    for d in range(num):
        sum += list[d]
    print(sum)

Submission status: Accepted

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

  counter = 0

  for i in range(N+1):
    if i%3 == 0 and i%5 == 0:
      pass
    elif i%3 == 0 :
      pass
    elif i%5 == 0:
      pass
    else:
      counter += i
    
  print(counter)


if __name__ == "__main__":
  main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# 初期入力
N = int(input())

#
fizbuz =[]
fizbuz_2 =[]
for i in range(1,N+1):
    if i%5 ==0 or i%3 ==0 :
        fizbuz_2.append("fizbuz")
    
    else:
        fizbuz.append(i)
print(sum(fizbuz))

#print(fizbuz)

Submission status: Accepted

Solution code:
N = int(input())

SUM = N*(N+1)/2
# print(str(SUM))

Fizz_count = N//3
Buzz_count = N//5
FizzBuzz_count = N//15

## r>1
def GeometricProgression(a_1,r,n):
    return int(a_1*(r^n -1)/r-1)

def Touhi(a_1,d,n):
    return int(n*(2*a_1+(n-1)*d)/2)

# print(Touhi(1,1,5))

SUM_Fizz = Touhi(3,3,Fizz_count)
SUM_Buzz = Touhi(5,5,Buzz_count)
SUM_FizzBuzz = Touhi(15,15,FizzBuzz_count)

"""
print(str(SUM_Fizz))
print(str(SUM_Buzz))
print(str(SUM_FizzBuzz))
"""

result = int(SUM - SUM_Fizz - SUM_Buzz + SUM_FizzBuzz)
print(result)

Submission status: Accepted

Solution code:
n = int(input())

three = (3+(n//3)*3) * (n//3)/2
five = (5+(n//5)*5) * (n//5)/2
cup = (15+(n//15)*15) * (n//15)/2
total = (1+n) * n/2

ans = total - three - five + cup

print(int(ans))

Submission status: Accepted

Solution code:
#--Fizz Buzz
N = int(input())

j = 0
for i in range(1, N+1):
  if i % 15 == 0:
    #fizzbuzz.append('FizzBuzz')
    pass
  elif i % 3 == 0:
    #fizzbuzz.append('Fizz')
    pass
  elif i % 5 == 0:
    #fizzbuzz.append('Buzz')
    pass
  else:
    j = j + i

print(j)

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())
a=0
for i in range(n+1):
    if i%3!=0 and i%5!=0:
            a+=i
print(a)

Submission status: Accepted

Solution code:
n = int(input())
s = (n*(n+1))//2
o = n//5
p = n//3
q = n//15

s -= (5*o*(o+1))//2
s -= (3*p*(p+1))//2
s += (15*q*(q+1))//2

print(s)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline

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

Submission status: Accepted

Solution code:
#coding: utf-8
 
N  = int(input())
sum = 0
 
for i in range(N+1):
    if ( i % 3 != 0):
        if (i % 5 != 0):
           sum += i
 
print(sum)

Submission status: Accepted

Solution code:
ans=0
N=int(input())
if N<=0:
    exit()
elif N>=1000001:
    exit()
else:

    for n in range(1,N+1):
        if n%15==0:
            n=str("FizzBuzz")
        elif n%3==0:
            n=str("Fizz")
        elif n%5==0:
            n=str("Buzz")
        else:
            ans+=n

print(ans)

Submission status: Accepted

Solution code:
N = int(input())
ans = 0
n3 = int(N/3)
n5 = int(N/5)
n15= int(N/15)
sn = int((N)*(N+1)/2)
s3 = 3 * int(((n3)*(n3+1)/2))
s5 = 5 * int(((n5)*(n5+1)/2))
s15= 15* int(((n15)*(n15+1)/2))

ans = sn-s3-s5+s15
print(ans)

Submission status: Accepted

Solution code:
N = int(input())

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

print(anw)

Submission status: Accepted

Solution code:
N = int(input())

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

print(ans)

Submission status: Accepted

Solution code:
a=int(input())
fizzbuzz = 0
for i in range(1,a+1):
  if (i%3) == 0:
      fizzbuzz += i
  elif (i%5) == 0:
      fizzbuzz += i
all_ = (1+a)*a/2
print(int(all_-fizzbuzz))

Submission status: Accepted

Solution code:
n = int(input())

fizzbuzz = [i for i in range(1, n+1) if not(i % 5 == 0 or i % 3 == 0)]
print(sum(fizzbuzz))

Submission status: Accepted

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

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

print(total)

Submission status: Accepted

Solution code:
n = int(input())
a = []
b = []
c = []
d = []

for i in range(n+1):
  if i%1 == 0:
    a.append(i)
    
for j in range(n+1):
  if j%3 == 0:
    b.append(j)
    
for k in range(n+1):
  if k%5 == 0:
    c.append(k)

for l in range(n+1):
  if l%3 == 0 and l%5 == 0:
    d.append(l)

print(sum(a)-sum(b)-sum(c)+sum(d))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(1000000)
n = int(input())
a = 0
for i in range(n+1):
    if (i % 3 !=0) and (i % 5 !=0):
        a += i
    else:
        continue
print(a)

Submission status: Accepted

Solution code:
# N項目までを指定する数字sの標準入力を得る
s = int(input())
myList = list(range(1,s+1))
newList = []
otherList = []

for number in myList:
  if number % 15 == 0:
    otherList.append(number)
  elif number % 5 == 0:
    otherList.append(number)
  elif number % 3 == 0:
    otherList.append(number)
  else:
    newList.append(number)

print(sum(newList))

Submission status: Accepted

Solution code:
import numpy as np
import sys
import math

# n = map(int,input().split())

ans = 0
n = int(input())

for x in range(n+1):
    if x % 3 == 0 and x % 5 == 0:
        continue

    if x % 3 == 0:
        continue

    if x % 5 == 0:
        continue

    ans += x

print(ans)

Submission status: Accepted

Solution code:
N = int(input())
f = N//3
b = N//5
fb = N//15
S = int(N*(N+1)/2)
F = int((3+3*f)*f/2)
B = int((5+5*b)*b/2)
FB = int((15+15*fb)*fb/2)
s = S-F-B+FB
print(s)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
sum = 0
while n > 0:
	if n%3 == 0:
		sum = sum + 0
	elif n%5 == 0:
		sum = sum + 0
	else :
		sum = sum + n
	n = n - 1
print(sum)

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:
i=int(input())
i1=i*(i+1)//2
i2=i//3
i3=i//5
i4=i2*(i2+1)//2
i5=i3*(i3+1)//2
i6=i//15
i7=i6*(i6+1)//2
print(i1-i4*3-i5*5+i7*15)

Submission status: Accepted

Solution code:
#!/usr/bin/python3
N = int(input())
wa = 0
for i in range(1,N+1):
    if i % 3 != 0 and i % 5 != 0 and i % 15 != 0:
        wa += i
print(wa)

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 = sum +i
print(sum)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math

x=int(input())
s=math.floor(x/3)
f=math.floor(x/5)
sf=math.floor(x/15)
sum=math.floor(x*(x+1)/2)

s_sum=math.floor(3*s*(s+1)/2)
f_sum=math.floor(5*f*(f+1)/2)
sf_sum=math.floor(15*sf*(sf+1)/2)

fl=sum-(s_sum+f_sum-sf_sum)
print(math.floor(fl))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

print(ans)

Submission status: Accepted

Solution code:
N = int(input())
line = []

for i in range(1,N+1):
  if i%15 == 0:
    i = 0
  elif i%3 == 0:
    i = 0
  elif i%5 == 0:
    i = 0
  else:
    i = i
  line.append(i)
ans = sum(line)

print(ans)

Submission status: Accepted

Solution code:
N = int(input())

result = 0

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

print(result)

Submission status: Accepted

Solution code:
K=int(input())
fiz=[0]
for i in range(K+1):
    if i%3==0 or i%5==0:
        k=1
    else:
        fiz.append(i)
print(sum(fiz))

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 or (i%3==0 and i%5==0):
        continue
    Sum+=i
print(Sum)

Submission status: Accepted

Solution code:
def extract(seq):
    arr = []
    for i in seq:
        if i % 3 == 0 or i % 5 == 0:
            continue
        else:
            arr.append(i)
    return sum(arr)


n = int(input())
print(extract(range(1, n + 1)))

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)
#print(1%3)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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:
N = int(input())
S = 0
for i in range(1, N+1):
    if i%3==0 or i%5==0 or (i%3==0 and i%5==0):
        continue
    S+=i
print(S)

Submission status: Accepted

Solution code:
N = int(input())

cnt = 0

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

print(cnt)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def resolve():
    N = int(input())
    temp = 0
    for count in range(N + 1):
        if count % 3 == 0 and count % 5 == 0:
            pass
        elif count % 3 == 0:
            pass
        elif count % 5 == 0:
            pass
        else:
            temp += count
    print(temp)


resolve()

Submission status: Accepted

Solution code:
n = int(input())

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())
i=int (0)
S=0
for i in range(N+1):
    if i%15!=0 and i%3!=0 and i%5!=0:
        S+=i
        
print(S)

Submission status: Accepted

Solution code:
def main():
    n = int(input())
    s = sum([i for i in range(1, n+1) if (i%3 > 0 and i%5 > 0)])
    print(s)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n = int(input())

s = (n//15)*60 + (n//15)*(n//15 - 1)*60

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

print(s)

Submission status: Accepted

Solution code:
N = int(input())
A = list(range(1 ,(N+1)))

S = [a for a in A if a % 3 != 0]
M = [s for s in S if s % 5 != 0]

print(sum(M))

Submission status: Accepted

Solution code:
n = int(input())
fg = list(range(n+1))
fg.pop(0)
total = 0
for i in range(n):
    if fg[i] % 15 == 0:
        fg[i] = 'FizzBuzz'
    elif fg[i] % 3 == 0:
        fg[i] ='Fizz'
    elif fg[i] % 5 == 0:
       fg[i] = 'Buzz'

for i in range(n):
    if not (fg[i] == 'FizzBuzz' or fg[i] == 'Fizz' or fg[i] == 'Buzz'):
        total += fg[i]

print(total)

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 = []
for i in range(1, N+1):
    if i % 15 == 0:
        continue
#         print("FizzBuzz")
    elif i % 3 == 0:
        continue
#         print("Fizz")
    elif i % 5 == 0:
        continue
#         print("Buzz")
    else:
        ans.append(i)
print(sum(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:
N = int(input())
sum = 0
for i in range(1, N+1, 1):
    if i%5 != 0 and i%3 != 0:
        sum += i
print(sum)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = input()
a = list()
for i in range(1,int(N)+1):
    if i % 3 == 0 or i % 5 == 0:
        continue
    else:
        a.append(i)
print(sum(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 and i % 15 != 0:
        ans = 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 or i%5==0:
        continue
    ans+=i
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

sm = 0

for a in range(1,N+1):
    if a%5 == 0 and a%3 == 0:
        continue
    if a%3 == 0:
        continue
    if a%5 == 0:
        continue
    sm += a

print(sm)

Submission status: Accepted

Solution code:
import sys

n = int(input())
  
f = sum(range(0, n+1, 3))
b = sum(range(0, n+1, 5))
fb = sum(range(0, n+1, 15))
total = (n * (n + 1)) / 2

# print(f, b, fb)
# print(total)
print(int(total - f -b + fb))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = input()

ans = 0
for i in xrange(1, n + 1):
    if i % 3 == 0 or i % 5 == 0: continue
    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:
a = int(input())
s = 0
for i in range(a+1):
 if(i%3!=0 and i%5!=0) :
   s+=i
print (s)

Submission status: Accepted

Solution code:
fizz = []
buzz = []
fizzbuzz = []
other = []
n = int(input())
for i in range(n):
    temp = i+1
    if (temp % 3 != 0) & (temp % 5 != 0):
        other.append(temp)

b = sum(other)

print(b)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N=int(input())

z=N//15
ans=60*z+60*z*(z-1)


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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N  = int(input())
num3 = N//3
sum3 = 3*num3*(num3+1)//2
num5 = N//5
sum5 = 5*num5*(num5+1)//2
num15 = N//15
sum15 = 15*num15*(num15+1)//2

_sum = N*(N+1)//2

print(_sum-sum3-sum5+sum15)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
a = 0
for n in range(1, N+1):
    if n%3 == 0 or n%5 == 0:
        continue
    else:
        a += n
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 = ans+i

print(ans)

Submission status: Accepted

Solution code:
#-*- coding: utf-8 -*-

N = int(input())
result = 0

for i in range(N):
  if not (i+1) % 3 == 0:
    if not (i+1) % 5 == 0:
      result = result + i + 1
      
print(result)

Submission status: Accepted

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

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 = sum +i
print(sum)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

b = 0

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

print(b)

Submission status: Accepted

Solution code:
n=int(input())
ans=0
i = 1
while i <= n:
    if i % 15 == 0:
      i += 1
    elif i % 3 == 0:
      i += 1
    elif i % 5 == 0:
      i += 1
    else:
      ans += i
      i += 1
    
print(ans)

Submission status: Accepted

Solution code:
# 入力は一行のみで[数値]

input_num = int(input())

answer = 0

for i in range(input_num):
    i = i+1
    if i%3 == 0:
        pass
    elif i%5 == 0:
        pass
    else:
        answer = answer + i

print(answer)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
a = [i for i in range(n+1) if i%3!=0]
b = [j for j in a if j%5!=0]
c = [k for k in b if k%15!=0]
print(sum(c))

Submission status: Accepted

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