Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save jennyonjourney/a1d5d7ccb7315f3e32f6669c76060e9a to your computer and use it in GitHub Desktop.
Save jennyonjourney/a1d5d7ccb7315f3e32f6669c76060e9a to your computer and use it in GitHub Desktop.
Python - funtion2
def cumsum(num):
res=0
for i in range(num+1):
res+=i
return res
print(cumsum(10))
print(cumsum(20))
print(cumsum(30))
hap = 0
for i in range(5):
hap+=i
print(hap)
#숫자 한개를 입력받아 소수인지 아닌지 출력해 주세요.
def primeNum(num):
for i in range(2,num):
if not num % i:
print('소수가 아님')
return
print('소수임')
primeNum(100)
#숫자 한개를 입력받아 소수인지 아닌지 출력해 주세요.
def primeNum(num):
res = '소수임'
for i in range(2,num):
if not num % i: #나눠지는 게 한개라도 있다면
print('소수가 아님')
break
print(res)
primeNum(17)
#0이면 false -> not false -> true
#0외에 다른값 true -> not true -> false
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment