Skip to content

Instantly share code, notes, and snippets.

@kms0219kms
Created January 5, 2026 13:16
Show Gist options
  • Select an option

  • Save kms0219kms/bc584cfbbdf62bed8854331c0f38975d to your computer and use it in GitHub Desktop.

Select an option

Save kms0219kms/bc584cfbbdf62bed8854331c0f38975d to your computer and use it in GitHub Desktop.
2025-2026 오성고_공동교육_정보과학 Day 1
def main():
n = int(input("숫자를 입력하세요: "))
total = 0
for i in range(1, n + 1):
total += i
print("합계:", total)
if __name__ == "__main__":
main()
def main():
n = int(input("숫자를 입력하세요: "))
total = 0
i = 1
while i <= n:
total += i
i += 1
print("합계:", total)
if __name__ == "__main__":
main()
def main():
n = int(input("숫자를 입력하세요: "))
total = n * (n + 1) // 2
print("합계:", total)
if __name__ == "__main__":
main()
def main():
n = int(input("숫자를 입력하세요: "))
total = sum(range(1, n + 1))
print("합계:", total)
if __name__ == "__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment