MapleStory Finger Point

๐Ÿ’Ž Python/Python_Code

N์˜ ๋ฐฐ์ˆ˜ ๊ฑด๋„ˆ๋›ฐ๊ณ  ์ถœ๋ ฅ - ํŒŒ์ด์ฌ for Beginner (2ํŒ)

HYEJU01 2024. 3. 20. 01:21

3์œผ๋กœ ๋‚˜๋ˆด์„๋•Œ  ๋‚˜๋จธ์ง€๊ฐ€ 0์ธ ์ˆซ์ž๋Š” 3์˜ ๋ฐฐ์ˆ˜๊ฐ€ ๋œ๋‹ค.

์ฆ‰ for ๋ฌธ ์•ˆ์— ์กฐ๊ฑด๋ฌธ์„ ๋„ฃ์–ด Continue ๋ฅผ ๋„ฃ์–ด์ฃผ๋ฉด 3์˜ ๋ฐฐ์ˆ˜์ธ ๊ฒฝ์šฐ

ํ•˜๋‹จ sum ์— ๋ˆ„์ ์ด ๋˜์ง€ ์•Š๊ณ  ๊ฑด๋„ˆ๋›ฐ์–ด์ง„๋‹ค.

sum , i = 0, 0


for i in range(1,101) :
    if i % 3 == 0 :
        continue

    sum += i

print ("1~100ํ•ฉ๊ณ„ (3๋ฐฐ์ˆ˜ ์ œ์™ธ) %d " % sum)