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:
# B - FizzBuzz Sum

N = int(input())

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

print(sum(ans))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
array_length = int(input())
array_sum = 0
fizzbuzz_list = [3,5,15]

for i in range(array_length):
    loop_num = i + 1
    flag = 0
    for n in fizzbuzz_list:
        if loop_num % n == 0:
            flag = 1
    if flag == 0:
        array_sum = array_sum + loop_num

print(array_sum)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Wed May  6 01:07:46 2020

@author: shinba
"""
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%5!=0 and i%3!=0:
    a=a+i
print(a)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
ans=[]
for i in range(1,n+1):
  if i%3==0 or i%5==0:
    continue
  ans.append(i)
print(sum(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:
#!/usr/bin/env python3


def main():
    N = int(input())
    ans = 0

    for n in range(1, N + 1):
        if n % 3 != 0 and n % 5 != 0:
            ans += n
    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) 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())
su = 0

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

print(str(su))

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()) + 1
a = set(range(0, n))
fs = set(range(0, n, 3))
bs = set(range(0, n, 5))
print(sum(a - fs - bs))

Submission status: Accepted

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

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())
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())
print((n+n**2-3*(n//3)*(1+(n//3))-5*(n//5)*(1+(n//5))+15*(n//15)*(1+(n//15)))//2)

Submission status: Accepted

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

if n == 1:
    print('1')
    exit(0)

sum_n = int((1 + n) / 2 * n)
n3 = n // 3
n5 = n // 5
n15 = n // 15

sum_n3 = int((1 + n3) / 2 * n3) * 3
sum_n5 = int((1 + n5) / 2 * n5) * 5
sum_n15 = int((1 + n15) / 2 * n15) * 15

res = sum_n - sum_n3 - sum_n5 + sum_n15
print(res)

Submission status: Accepted

Solution code:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools
import time,random

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
mod2 = 998244353
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)
def pe(s): return print(str(s), file=sys.stderr)
def JA(a, sep): return sep.join(map(str, a))
def JAA(a, s, t): return s.join(t.join(map(str, b)) for b in a)


def main():
    n = I()
    r = sum(i for i in range(1, n+1) if i % 3 > 0 and i % 5 > 0)

    return r


print(main())

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
    elif i%3==0:
        total=total
    elif i%5==0:
        total=total
    else:
        total=total+i
print(total)

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

Submission status: Accepted

Solution code:
n = int(input())
l = list(range(1,n+1))
fz = list(range(3,n+1,3))
bz = list(range(5,n+1,5))
fzbz = list(range(15,n+1,15))
a = sum(l)-sum(fz)-sum(bz)+sum(fzbz)
print(a)

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10 ** 6)
# input = sys.stdin.readline    ####
int1 = lambda x: int(x) - 1
def II(): return int(input())

def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())

def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

INF = float('inf')

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

    print(ans)

if __name__ == '__main__':
    solve()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
A = int(input())
a = list(range(1,A+1))
sum=0
for i in a:
    if i % 3 == 0 or i % 5 ==0:
        pass
    else:
        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 = [0]*n
for i in range(1,n+1):
  if (i%3==0 and i%5==0) or i%3==0 or i%5==0:
    continue
  else:
    a[i-1] += i

print(sum(a))

Submission status: Accepted

Solution code:
import math
import queue
from collections import defaultdict
 
def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()
def factorization(n):
	res = []
	if n%2==0:
		res.append(2)
	for i in range(3,math.floor(n//2)+1,2):
		if n%i==0:
			c = 0
			for j in res:
				if i%j==0:
					c=1
			if c==0:
				res.append(i)
	return res
def fact2(n):
	p = factorization(n)
	res = []
	for i in p:
		c=0
		z=n
		while 1:
			if z%i==0:
				c+=1
				z/=i
			else:
				break
		res.append([i,c])
	return res
def fact(n):#階乗
	ans = 1
	m=n
	for _i in range(n-1):
		ans*=m
		m-=1
	return ans
def comb(n,r):#コンビネーション
	l = min(r,n-r)
	m=n
	u=1
	for _i in range(l):
		u*=m
		m-=1
	return u//fact(l)
def printQueue(q):
	r=q
	ans=[0]*r.qsize()
	for i in range(r.qsize()-1,-1,-1):
		ans[i] = r.get()
	print(ans)

N = readInt()
ans = 0

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline
N = int(readline())

def sum(l, r, d):
    return (l+r)*((r-l)//d+1)//2

print(sum(1,N,1) - sum(3,N-N%3,3) - sum(5,N-N%5,5) + sum(15,N-N%15,15))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input().strip())

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

Submission status: Accepted

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

for i  in range (n):
    i += 1
    if (i%3==0 and i%5==0) or i%3==0 or i%5==0:
        continue
    else:
        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:
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop
from itertools import permutations, accumulate, combinations
from math import sqrt, ceil, floor
from bisect import bisect_left, bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
import sys
def I(): return int(input())  # '123' -> 123
def Is(): return map(int, input().split())  # '123 456' -> 123, 456
def LI(): return list(map(int, input().split()))  # '123 456' -> [123, 456]
def TI(): return tuple(map(int, input().split()))  # '123 456' -> (123, 456)
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def TIR(n): return [TI() for _ in range(n)]
def S(): return input()
def Ss(): return input().split()  # 'aa bb' -> 'aa','bb' or ['aa','bb']
def LS(): return list(input())  # 'abc123' -> ['a','b','c','1','2','3']
def SR(n): return [S() for _ in range(n)]
def SsR(n): return [Ss() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
sys.setrecursionlimit(1000000)
MOD = 1000000007
INF = float('inf')

N = I()

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%5 != 0 and i%3 != 0:
        ans += i

print(ans)

Submission status: Accepted

Solution code:
N = int(input())
a = list(range(1,N+1))
N_3 = N//3
N_5 = N//5
for i in range(1,N_3+1):
    a[3*i-1] = 0
for i in range(1,N_5+1):
    a[5*i-1] = 0
print(sum(a))

Submission status: Accepted

Solution code:
#import math
#input()
n=int(input())
#map(int,input().split())
#list(map(int,input().split()))
#[input() for _ in range()]

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
def fizzbuzz_sum(n: int) -> int:
    return sum(i if i % 3 != 0 and i % 5 != 0 else 0 for i in range(1, n + 1))

N = int(input())
print(fizzbuzz_sum(N))

Submission status: Accepted

Solution code:
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 or i%5==0:continue
	else:
		ans+=i
print(ans)

Submission status: Accepted

Solution code:
# coding: utf-8

N=int(input())
count = 0


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

Submission status: Accepted

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

print(x)

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 : #1~Nまで３の倍数かつ５の倍数でないものを探す
        ans += i     #+=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())
count=0
for i in range(1,n+1):
    if  i%5 != 0 and  i%3 != 0:
        count += i
print(count)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
ans = 0
for i in range(1, int(input()) + 1):
    if not (i  % 3 == 0 or i % 5 == 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())
l=[]

for i in range(1,n+1):
    if i%3!=0 and i%5!=0:
        l.append(i)
#print(l)
sum=0
for i in l:
        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())

list = []

count = 1

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

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10**6)
ii = lambda: int(input())
mis = lambda: map(int,input().split())
lmis = lambda: list(mis())
INF = float('inf')

def main():
    n=ii()
    cnt=0
    for i in range(n+1):
        if i%3!=0 and i%5!=0:cnt+=i
    print(cnt)


if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=int(input())
a=[0]*n
sa=0
for i in range(1,n+1):
    if i%15==0:
        a[i-1]="FizzBuzz"
    elif i%3==0:
        a[i-1]="Fizz"
    elif i%5==0:
        a[i-1]="Buzz"
    else:
        a[i-1]=str(i)
        sa+=i
print(sa)

Submission status: Accepted

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

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

print(sum)

Submission status: Accepted

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

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

print(sum)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

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

Submission status: Accepted

Solution code:
N = int(input())

array = [i + 1 for i in range(N)]
res_array = []

for i in range(N):
  if array[i] % 3 != 0 and array[i] % 5 != 0:
    res_array.append(array[i])

print(sum(res_array))

Submission status: Accepted

Solution code:
# coding: utf-8
ans = 0
N = int(input())
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())
ans = 0
for i in range(N):
  if((((i+1)%3) == 0)or(((i+1)%5) == 0)):
    ans = ans
  else:
    ans = ans + i+1
    
    
    
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
    N = int(input())
    l=[]
    for i in range(1, N+1):
        if not(i%5==0 or i%3==0):
            l.append(i)
    x = 0
    for i in l:
        x = x + i
    print(x)
main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
a = list(range(N+1))
ans = sum(a)

for i in range(N+1):
  y = a[i]
  if y%3 == 0 or y%5 == 0:
    ans -= y
    
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

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

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

Submission status: Accepted

Solution code:
n = int(input())
A = list(range(1, n+1))
B = list()
for i in range(1, n+1):
    if i % 5 == 0 or i % 3 == 0:
        B.append(i)
ans = list(set(A) - set(B))
print(sum(ans))

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:
    pass
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())
l = 0
for i in range(1, N+1):
    if i % 3 != 0:
        if i % 5 != 0:
            l += i
print(l)

Submission status: Accepted

Solution code:
N=int(input())

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

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

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:
a=int(input())
b=[]
for i in range(a+1):
    if i%3==0 or i%5==0:
        continue
    else:
        b.append(i)
print(sum(b))

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

fizzbuzz = []

for i in range(1, N+1):
    if i % 3 == 0 or i % 5 == 0:
        fizzbuzz.append('0')
    else:
        fizzbuzz.append(str(i))

num = [int(s) for s in fizzbuzz]
print(sum(num))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

# output
print(sum)

Submission status: Accepted

Solution code:
s=lambda x:x*(x+1)//2;print(s(n:=int(input()))-s(n//3)*3-s(n//5)*5+s(n//15)*15)

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())
f = n//3
s_f = 3*f*(f+1)/2
b = n//5
s_b = 5*b*(b+1)/2
fb = n//15
s_fb = 15*fb*(fb+1)/2
print(int(n*(n+1)/2-s_f-s_b+s_fb))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#-*- coding: utf-8 -*-
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:
#-*- coding: utf-8 -*-
n = int(input())
sum = 0
for i in range(1,n + 1):
    if i % 3 != 0 and i % 5 != 0 and i % 15 != 0:
        sum += i

print(sum)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import numpy as np
a = np.array([i for i in range(1, int(input())+1)])
print(a[np.where((a % 3 != 0) & (a % 5 !=0))].sum())

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

Sum = (1+N)*N/2
Fizz = ((1+N//3)*(N//3))/2*3
Buzz = ((1+N//5)*(N//5))/2*5
FizzBuzz = ((1+N//15)*(N//15))/2*15
print (int(Sum-Fizz-Buzz+FizzBuzz))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

res = 0
for i in range(N):
  if (i+1) % 3 == 0 or (i+1) % 5 == 0:
    res += 0
  else:
    res += (i+1)
    
print(res)

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

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

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
n = int(input())

s = set(range(1,n+1))
s3 = {i for i in range(1,n+1) if i % 3 == 0}
s5 = {i for i in range(1,n+1) if i % 5 == 0}

diff = s.difference(s3,s5)
print(sum(diff))

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

Submission status: Accepted

Solution code:
def main(n):
    res = 0
    for i in range(1,n+1):
        if i % 3 != 0 and i % 5 != 0:
            res += i
    return res

n = int(input())
print(main(n))

Submission status: Accepted

Solution code:
n = int(input())

a = n // 15
b = n // 3
c = n // 5

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

Submission status: Accepted

Solution code:
n=int(input())
an=[a for a in range(1,n+1)]
o=[]
def ass(an):
    for c in an:
        if c%3==0 or c%5==0:
             continue
        else:
            o.append(c)
    return sum(o)
print(ass(an))

Submission status: Accepted

Solution code:
#ABC 162 B
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())
A = 0
for i in range(N):
    if (i+1)%3 != 0 and (i+1)%5 != 0:
        A += i + 1
print(A)

Submission status: Accepted

Solution code:

def read_int():
    return int(input().strip())


def read_ints():
    return list(map(int, input().strip().split(' ')))


def sums(a, N): 
    ans = ((N//a)*((N//a)+1)//2)*a
    return ans 


def solve():
    N = read_int()
    return N*(N+1)//2-(sums(3, N)+sums(5, N)-sums(15, N)) 


if __name__ == '__main__':
    print(solve())

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!
N = int(input())
ans = 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
    else:
        ans+=i
    
print(ans)

Submission status: Accepted

Solution code:
import numpy as np
N = int(input())
if N >= 2 :
    An = np.zeros(N+2, dtype=np.int)
    #An = [[] for _ in range(1,N+2)]
    #print(An)
    for s in range(1,N+1) :
        #print(s)
        if s%3 != 0 and s%5 != 0 :
            An[s] = int(s) 
            #print(s)
            #print(An[s])
    ans = np.sum(An)

else:
    ans = int(1)

print (int(ans))

Submission status: Accepted

Solution code:
N = int(input())
all = []
n = []

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

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:
        continue
    
    ans += i

print(ans)

Submission status: Accepted

Solution code:
N = int(input())

N_list = list(range(1, N + 1))

ans = 0

for i in N_list:
    if not (i % 3 == 0 or i % 5 == 0):
        ans += i
print(ans)

Submission status: Accepted

Solution code:
N = int(input())

x = 0

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

Submission status: Accepted

Solution code:
a = int(input())
d = 1
D = 0
for I in range(a):
    if d%3 == 0:
        d += 1
    
    elif d%5 == 0:
        d += 1
        
    else:
        D = D + d
        d += 1
print(D)

Submission status: Accepted

Solution code:
n = int(input())

sum = (1+n)*n/2
sum3 =(3+ 3*(n//3))*(n//3)/2
sum5 =(5+ 5*(n//5))*(n//5)/2
sum15 =(15+ 15*(n//15))*(n//15)/2

print(int(sum-sum3-sum5+sum15))

Submission status: Accepted

Solution code:
N = int(input())

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

print(output)

Submission status: Accepted

Solution code:
import numpy as np

#入力
n = int(input())

#3の倍数をFに変更
def multiples_3(matrix):
    #列ベクトルを削除(3列目)
    m_de = np.delete(fizzbuzz_list,2, axis=1)
    #Fの列ベクトルを作成
    f_list = np.zeros(j).reshape(-1, 1)
    #結合
    result = np.concatenate([m_de, f_list], 1)
    return result

#列を計算(繰り上げ)
j = -(-n // 3)

#1からnまでの配列を作成
fizzbuzz_list = np.arange(1,n+1)
#要素数
before_size = fizzbuzz_list.size
#3*n行列に変更
fizzbuzz_list.resize((j,3))

#3の倍数をFに変更
fizzbuzz_list = multiples_3(fizzbuzz_list)

#5の倍数をBに変更
n_b_1 = np.arange(3,j,5)
n_b_2 = np.arange(1,j,5)

fizzbuzz_list[n_b_1,0] = 0
fizzbuzz_list[n_b_2,1] = 0

#15の倍数をFBに変更
n_fb = np.arange(4,j,5)
fizzbuzz_list[n_fb,2] = 0

print(int(np.sum(fizzbuzz_list)))

# np.where(fizzbuzz_list[:,2:3],fizzbuzz_list,"F")

Submission status: Accepted

Solution code:
import numpy as np

#入力
n = int(input())

#3の倍数をFに変更
def multiples_3(matrix):
    #列ベクトルを削除(3列目)
    m_de = np.delete(fizzbuzz_list,2, axis=1)
    #Fの列ベクトルを作成
    f_list = np.zeros(j).reshape(-1, 1)
    #結合
    result = np.concatenate([m_de, f_list], 1)
    return result

#列を計算(繰り上げ)
j = -(-n // 3)

#1からnまでの配列を作成
fizzbuzz_list = np.arange(1,n+1)
#要素数
before_size = fizzbuzz_list.size
#3*n行列に変更
fizzbuzz_list.resize((j,3))

#3の倍数をFに変更
fizzbuzz_list = multiples_3(fizzbuzz_list)

#5の倍数をBに変更
n_b_1 = np.arange(3,j,5)
n_b_2 = np.arange(1,j,5)

fizzbuzz_list[n_b_1,0] = 0
fizzbuzz_list[n_b_2,1] = 0

#15の倍数をFBに変更
n_fb = np.arange(4,j,5)
fizzbuzz_list[n_fb,2] = 0

sum = 0
sum = np.sum(fizzbuzz_list)
print(int(sum))

Submission status: Accepted

Solution code:
N=int(input())

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

print(sum(S))

Submission status: Accepted

Solution code:
n = int(input())

n3 = n - n%3
n5 = n - n%5
n15 = n - n%15


sum = n * (n+1) /2
sum3 = n3 * (n3 + 3) /6
sum5 = n5 * (n5 + 5) /10
sum15 = n15 * (n15 +15) /30

print(round(sum-sum3-sum5+sum15))