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:
number = int(input())

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# 162 B
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:
def resolve():
    n = int(input())
    ans = 0
    for i in range(1,n+1):
        if i%3!=0 and i%5!=0:
            ans += i
    print(ans)
resolve()

Submission status: Accepted

Solution code:
def to_fizzbuzz(number):
    if number % 15 == 0:
        return 'FizzBuzz'

    if number % 3 == 0:
        return 'Fizz'

    if number % 5 == 0:
        return 'Buzz'

    else:
        return str(number)
        # return i

def main():
    N = int(input())
    # this list concludes "FizzBuzz", "Fizz" or "Buzz"
    fblist = []
    for number in range(1, 10**6):
        result = to_fizzbuzz(number)
        fblist.append(result)

    # the list up to N
    n_list = fblist[0:N]
    # this list contains only numbers and up to N

    n_numlist = []

    for s in n_list:
        if s.isdigit() == True:
            n_numlist.append(int(s))

    print(sum(n_numlist))


main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

print(answer)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# 入力
n = int(input())

# 処理
sum = 0

for i in range(1, n + 1):
    if i % 15 == 0:
        i = 'FizzBuzz'
    elif i % 3 == 0:
        i = 'Fizz'
    elif i % 5 == 0:
        i = 'Buzz'
    else:
        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())

Ndiv3 = N // 3
Ndiv5 = N // 5
Ndiv15 = N // 15

ans = (N*(N + 1) - 3*Ndiv3*(Ndiv3 + 1) - 5*Ndiv5*(Ndiv5 + 1) + 15*Ndiv15*(Ndiv15 + 1))//2
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:
def main():
    n = int(input())
    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())

Flag = [False]*(N+1)
Flag[0] = True

num = 3
while num <= N:
    Flag[num] = True
    num += 3

num = 5
while num <= N:
    Flag[num] = True
    num += 5

count = 0
for f in range(1, N+1):
    if Flag[f] == False:
        count += f

print(count)

Submission status: Accepted

Solution code:
N = int(input())

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

print(ans)

Submission status: Accepted

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

for i in range(1, N + 1):
    if i % 3 == 0 and i % 5 == 0:
        "FizzBuzz"
    elif i % 3 == 0:
        "Fizz"
    elif i % 5 == 0:
        "Buzz"
    else:
        list.append(i)
print(sum(list))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
import math
from collections import defaultdict,deque

input = sys.stdin.readline
def inar():
    return [int(el) for el in input().split()]
def main():
    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)

if __name__ == '__main__':
    main()

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:
number = int(input())

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

print(answer)

Submission status: Accepted

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

Submission status: Accepted

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

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:
            i = ["FizzBuzz"]
        elif i % 3 == 0:
            i = ["Fizz"]
        elif i % 5 == 0:
            i = ["Buzz"]
    # if i % 3 == 0 and i % 5 == 0:
        else:
            sum += i
print(sum)

Submission status: Accepted

Solution code:
n=int(input())
str_n=str(n)
list_n=list(str_n)
count=0
for i in range(1,n+1):
	if(i%3==0 or i%5==0):
		count+=0
	elif(i%3==0):
		count+=0
	elif(i%5==0):
		count+=0
	else:
		count+=i

print(int(count))

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())
count = 0
for i in range(1,n+1):
  if i % 3 == 0:
    continue
  elif 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=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())
a=n//3
b=n//5
c=n//15

print(n*(n+1)//2-3*a*(a+1)//2-5*b*(b+1)//2+15*c*(c+1)//2)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

f = n//3
b = n//5
fb = n//15

def s(x):
  return x*(x+1)/2

ans = s(n) - 3*s(f) - 5*s(b) + 15*s(fb)
print(int(ans))

Submission status: Accepted

Solution code:
n = int(input())
answer = 0 # 和の格納用

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

print(answer)

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:
print(sum([ x for _ in range(int(input())) if not ((x:=_+1)%3==0 or x%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())
S = 0

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

Submission status: Accepted

Solution code:
N = int(input())

S = []

for i in range(1, N + 1):
    if i % 3 != 0 and i % 5 != 0:
        S.append(i)
    else:
        pass

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

print(sum)

Submission status: Accepted

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

Submission status: Accepted

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


main()

Submission status: Accepted

Solution code:
ans = 0
for i in range(1,int(input())+1):
  if i%3==0 or i%5==0:
    continue
  else:
    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:
            i = ["FizzBuzz"]
        elif i % 3 == 0:
            i = ["Fizz"]
        elif i % 5 == 0:
            i = ["Buzz"]
    # if i % 3 == 0 and i % 5 == 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 += i

print(sum)

Submission status: Accepted

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

print(count)

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 not i % 3 == 0 and not i % 5 == 0:
        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:
import numpy as np
def main():
    n = int(input())
    x = np.arange(n + 1)
    x[x % 3 == 0] = 0
    x[x % 5 == 0] = 0
    print(x.sum())

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
#ABC162B
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())
l = [i for i in range(1, N + 1) if i % 3 != 0 and i % 5 != 0]
s = sum(l)
print(s)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
num = int(input())

ls = []

for i in range(num):
    ls.append(True)

f = 3
z = 5

while f <= num:
    ls[f-1] = False
    f += 3

while z <= num :
    ls[z-1] = False
    z += 5

ans = 0

for i in range(num):
    if ls[i]:
        ans += i+1
    
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

i = 1
sum = 0
while True:
  if i%3!=0 and i%5!=0:
    sum +=i
  i+=1
  if i==N+1:
    break
    
print (sum)

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 i in range(1, N + 1):
    if i % 15 == 0:
        s = s # print("FizzBuzz")
    elif i % 3 == 0:
        s = s # print("Fizz")
    elif i % 5 == 0:
        s = s # print("Buzz")
    else:
        # print(i)
        s = s+i
print(s)

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

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

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:
import sys
import numpy as np
from math import ceil as C, floor as F, sqrt
from collections import defaultdict as D, Counter as CNT
from functools import reduce as R
import heapq as HQ

class Heap:
  def __init__(self, data, reverse=False):
    self.reverse = -1 if reverse else 1
    self.data = [self.reverse * d for d in data]
    HQ.heapify(self.data)
  def push(self, x): return HQ.heappush(self.data, self.reverse * x)
  def pop(self): return self.reverse * HQ.heappop(self.data)

ALP = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
alp = 'abcdefghijklmnopqrstuvwxyz'
def _X(): return sys.stdin.readline().rstrip().split(' ')
def _S(ss): return tuple(ss) if len(ss) > 1 else ss[0]
def S(): return _S(_X())
def Ss(): return list(S())
def _I(ss): return tuple([int(s) for s in ss]) if isinstance(ss, tuple) else int(ss)
def I(): return _I(S())
def _Is(ss): return list(ss) if isinstance(ss, tuple) else [ss]
def Is(): return _Is(I())

n = I()

def fizzbuzz(i):
    return i % 3 == 0 or i % 5 == 0

print(np.sum([i for i in range(n+1) if not fizzbuzz(i)]))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math
import sys
import os
from operator import mul

sys.setrecursionlimit(10**7)

def _S(): return sys.stdin.readline().rstrip()
def I(): return int(_S())
def LS(): return list(_S().split())
def LI(): return list(map(int,LS()))

if os.getenv("LOCAL"):
    inputFile = basename_without_ext = os.path.splitext(os.path.basename(__file__))[0]+'.txt'
    sys.stdin = open(inputFile, "r")
INF = float("inf")


N = I()
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())
a = []

for x in range(1,n+1):
  if x % 15 == 0:
    x = "FizzBuzz"
  elif x % 3 == 0:
    x = "Fizz"
  elif x % 5 == 0:
    x = "Buzz"
  else :
    a.append(x)
  

print(sum(a))

Submission status: Accepted

Solution code:
N = int(input())
ans = 0
for n in range(1, N+1):
    if n % 3 == 0 and n % 5 == 0:
        pass
    elif n % 3 == 0:
        pass
    elif n % 5 == 0:
        pass
    else:
        ans += n % (10**9+7)
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())
s = 0
i = 1
while i <= N:
    if i % 3 != 0 and i % 5 != 0:
        s += i
    i += 1
print(s)

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:
        pass
    else:
        s += i
print(s)

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 = input()

answer = 0

for i in range(1, int(N) + 1):
    if (i % 3 > 0) and (i % 5 > 0):
        answer += i

print(answer)

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

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())
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())
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:標準入力
N = int(input())

# 結果の出力のための変数定義
result = 0

# Nまでの条件以外の繰り返しの合計
for i in range(1, N + 1):
    if i % 15 == 0:
        result += 0
    elif i % 3 == 0:
        result += 0
    elif i % 5 == 0:
        result += 0
    else:
        result += i
print(result)

Submission status: Accepted

Solution code:
# FizzBuzzの整数部分の総和を求めよ

# FizzBuzz試し
# N = input()
# for i in range(1,int(N)+1):
#     if (i % 3 == 0) and (i % 5 == 0):
#         answer = 'FizzBuzz'
#     elif i % 3 == 0:
#         answer = 'Fizz'
#     elif i % 5 == 0:
#         answer = 'Buzz'
#     else:
#         answer = int(i)
#     print(answer)

N = input()
I = []
for i in range(1,int(N)+1):
    if (i % 3 != 0) and (i % 5 != 0):
        I.append(i)
# print(I)
Sum = sum(I)
print(Sum)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
N = int(input())
def f(n):
    k = N // n
    return n * k * (k+1) // 2
ans = f(1) - f(3) - f(5) + f(15)
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())
sum = 0

if (1 <= N and N <= 10 ** 6):

    for i in range(1,N + 1):
        if ( i % 3 == 0) and ( i % 5 == 0):
        #if i % 15 ==0:
            N = 'Fizz Buzz'
        elif i % 3 == 0:
            N = 'Fizz'
        elif i % 5 == 0:
            N = 'Buzz'
        else:
            sum += i
    print(sum)

Submission status: Accepted

Solution code:
# B - FizzBuzz Sum

n = int(input())

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

print(s)

Submission status: Accepted

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

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

print(sum)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
total = []

for i in range(1, n + 1):
    if i % 15 == 0:
        "FizzBuzz"
    elif i % 3 == 0:
        "Fizz"
    elif i % 5 == 0:
        "Buzz"
    else:
        total.append(i)

print(sum(total))

Submission status: Accepted

Solution code:
n = int(input())
total = []

for i in range(1, n + 1):
    if (i % 3 == 0) and (i % 5 == 0):
        "FizzBuzz"
    elif i % 3 == 0:
        "Fizz"
    elif i % 5 == 0:
        "Buzz"
    else:
        total.append(i)

print(sum(total))

Submission status: Accepted

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

print(sum(number_list))

Submission status: Accepted

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

print(sum(number_list))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# 入力
a = int(input())

# 定義
answer = 0

# 処理
for i in range(1, a + 1):
    if i % 3 == 0 and i % 5 == 0:
        continue
    elif i % 3 == 0:
        continue
    elif i % 5 == 0:
        continue
    else:
        answer += i

# 出力
print(answer)

Submission status: Accepted

Solution code:
# FizzBuzzSUM

N = int(input())

S = []

for i in range(1, N+1 ):
    if i % 3 != 0 and i % 5 != 0 :
        S.append(i)
    else:
        pass

print(sum(S))

Submission status: Accepted

Solution code:
n=int(input())

a=0
b=0
c=0

for i in range(1,n//3+1):
  a+=3*i

for i in range(1,n//5+1):
  b+=5*i
 
for i in range(1,n//15+1):
  c+=15*i
  
print(int(1/2*n*(n+1)-(a+b-c)))

Submission status: Accepted

Solution code:
total = 0

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

total = []

for i in range(1, n + 1):
    if i % 15 == 0:
        "FizzBuzz"
    elif i % 5 == 0:
        "Buzz"
    elif i % 3 == 0:
        "Fizz"
    else:
        total.append(i)

print(sum(total))

Submission status: Accepted

Solution code:
N=int(input())
lis=[0]*(N+10)
i=1

while i<=N:
  if i%3!=0 and i%5!=0:
    lis[i]=i
  i+=1
print(sum(lis))

Submission status: Accepted

Solution code:
#   FizzBuzzSum

total = 0
n = int(input())
for i in range(1, n + 1):
    if not ((i % 5 == 0) or (i % 3 == 0)):
        total = total + i
print(total)
#   Fizz:(i%3==0)
#   Buzz:(i%5==0)
#   FizzBuzz:(i%3==0)and(i%5==0)
#   ベン図を描けば一目瞭然

Submission status: Accepted

Solution code:
#   FizzBuzzSum

sum = 0
n = int(input())
for i in range(1, n + 1):
    if not ((i % 5 == 0) or (i % 3 == 0)):
        sum = sum + i
print(sum)
#   Fizz:(i%3==0)
#   Buzz:(i%5==0)
#   FizzBuzz:(i%3==0)and(i%5==0)
#   ベン図を描けば一目瞭然

Submission status: Accepted

Solution code:
n = int(input())

total = []


for i in range(1, n + 1):
    if i % 15 == 0:
        "FizzBuzz"
    elif i % 5 == 0:
        "Buzz"
    elif i % 3 == 0:
        "Fizz"
    else:
        total.append(i)  # リストに加える
print(sum(total))

Submission status: Accepted

Solution code:
n = int(input())
list = []

for i in range(1, n + 1):
    if i % 3 == 0 and i % 5 == 0:
        'FizzBuzz'
    elif i % 3 == 0:
        'Fizz'
    elif i % 5 ==0 :
        'Buzz'
    else:
        list.append(i)

print(sum(list))

Submission status: Accepted

Solution code:
n = int(input())
Total = []

for i in range(1, n + 1):

    if (i % 3 == 0) and (i % 5 == 0):
        "FizzBuzz"
    elif i % 3 == 0:
        "Fizz"
    elif i % 5 == 0:
        "Buzz"
    else:
        Total.append(i)

print(sum(Total))

Submission status: Accepted

Solution code:
# 162b

N = int(input())
sum = 0 # 数字の場合の和を格納する変数

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

print(sum)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# 1 <= N <= 1000000
N = int(input())

total = []

# N項目までに含まれる->N項目は含まない。だからN項目は+1で外す。
for x in range(1, N+1):
    if x % 15 == 0:
        "FizzBuzz"
    elif x % 5 == 0:
        "Buzz"
    elif x % 3 == 0:
        "Fizz"
    else:
        total.append(x) #リストに加える
print(sum(total))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
number = int(input())
Total = []

for i in range(1, number + 1):
    if number % 3 == 0 and i % 5 ==0:
        "FizzBuzz"
    elif i % 3 ==0:
        "Fizz"
    elif i % 5 == 0:
        "Buzz"
    else:
        Total.append(i)

print(sum(Total))

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
n = int(input())
total = []  

for i in range(1, n + 1):
    if i % 3 == 0 and i % 5 == 0:
        "FizzBuzz"
    elif i % 3 == 0:
        "Fizz"
    elif i % 5 == 0:
        "Buzz"
    else:
        total.append(i)  
print(sum(total))

Submission status: Accepted

Solution code:
# 入力
n = int(input())

# 出力
answer = 0
for i in range(1, n + 1):
    if not i % 3 == 0 and not i % 5 == 0:
        answer += i

print(answer)

Submission status: Accepted

Solution code:
#N番目の数字を入力待機している
N = int(input())

#合計の変数にsumを使用
sum = 0
#入力してもらうNまで1ずつ増えていく。
for i in range(1, N + 1):
#3で割り切れない数字と、5で割り切れない数字の総和を求める
    if (i % 3 != 0) and (i % 5 != 0):
        sum += i

print(sum)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# B - FizzBuzz Sum

# 1～Nまでのループで、3でも5でも割り切れない数の総和を求める

N = int(input())
answer = 0

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

print(answer)

Submission status: Accepted

Solution code:
# FizzBuzz列の N項目 までに含まれる数の和を求めてください。

N = int(input())
answer = 0

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

print(answer)

Submission status: Accepted

Solution code:
# B - FizzBuzz Sum
# https://atcoder.jp/contests/abc162/tasks/abc162_b

N = int(input())

result = 0

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 = int(input())
x = 0
for i in range(1, n + 1):
    if i % 5 == 0 or i % 3 == 0:
        pass
    else:
        x += i

print(x)

Submission status: Accepted

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

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:
# FizzBuzzの数の和
N = int(input())

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

print(answer)

Submission status: Accepted

Solution code:
n = int(input())

sum = 0

for i in range(1, n + 1):
    if i % 15 == 0:
        sum += 0
    elif 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:
        if i % 5 != 0:
            SUM += i

print(SUM)

Submission status: Accepted

Solution code:
n = int(input())

sum = (1 + n) * n // 2

sho_3 = n // 3
sho_5 = n // 5
sho_15 = n // 15

s_3 = (sho_3 * 3 + 3) * sho_3 // 2
s_5 = (sho_5 * 5 + 5) * sho_5 // 2
s_15 = (sho_15 * 15 + 15) * sho_15 // 2


print(sum - s_3 - s_5 + s_15)

Submission status: Accepted

Solution code:
# ゴール：3.5.15の倍数 以外の数字を合計したい
N = int(input())

sum_exclusion = 0  # 計算結果を入れる変数

for i in range(1, N + 1):
    if not (i % 15 == 0 or i % 3 == 0 or i % 5 == 0):
        sum_exclusion += i  # rangeが空になるまで、条件に合う数値が足されていく

print(sum_exclusion)

Submission status: Accepted

Solution code:
# abc162_b
# https://atcoder.jp/contests/abc162/tasks/abc162_b

# FizzBuzz Sum
# iが３、５で割り切れるなら　FizzBuzz
# iが３で割り切れるなら　Fizz
# iが５で割り切れるなら　Buzz
# 上記、以外はi

# FizzBuzz列のN項目までの数の和
# ３、５と３*５の時以外の数を加算していく

# 入力
n = int(input())

# 処理
sum_num = 0
for i in range(1, n + 1):
    if not i % 3 == 0 and not i % 5 == 0:
        sum_num += i

print(sum_num)

Submission status: Accepted

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

# 処理
sum = 0

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

# 出力
print(sum)

Submission status: Accepted

Solution code:
# B - FizzBuzz Sum

# 標準入力 N
N = int(input())
x = 0

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

print(x)

Submission status: Accepted

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

if (1 <= N and N <= 10 ** 6):
    for i in range(1, N + 1):
        if (i % 3 == 0 & i % 5 == 0):
            N = "FizzBuzz"
        elif i % 3 == 0:
            N = "Fizz"
        elif i % 5 == 0:
            N = "Buzz"
        else:
            sum += i
    print(sum)

Submission status: Accepted

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

Submission status: Accepted

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

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

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

for i in range(1, n + 1):       # range内を出力(i)していく
    if i % 3 != 0 and i % 5 != 0:
        answer += i             # iを足していったものがanswer
print(answer)                   # 実際に見えるように出力

Submission status: Accepted

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

Submission status: Accepted

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

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

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

print(sum(l))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
total = []

N = int(input())

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:
        total.append(i)

print(sum(total))