ex. 123, 98, 87 (1+2+3=6 / 9+8=17 / 8+7=15 >>>98이 제일 큼)
n = int(input('몇 개?:'))
a = list(map(int,input('n개의 숫자 리스트 입력').split()))
def digit_sum(x):
sum=0
while x > 0:
sum += x%10
x = x //10
return sum
max =- 2147000000
for x in a:
tot = digit_sum(x)
if tot > max:
max = tot
res = x
print(res)
n = int(input('몇 개?:'))
a = list(map(int,input('n개의 숫자 리스트 입력').split()))
def digit_sum(x):
sum=0
for i in str(x):
sum += int(i)
return sum
max =- 2147000000
for x in a:
tot = digit_sum(x)
if tot > max:
max = tot
res = x
print(res)
def reverse(x):
res = 0
while x > 0:
t=x%10
res = res*10 + t
x = x//10
return res
def isPrime(x):
if x == 1:
return False
for i in range(2,x//2+1):
if x%i == 0:
return False
else:
return True
n = int(input('몇 개?:'))
a = list(map(int,input('n개의 숫자입력').split()))
for x in a:
tmp=reverse(x)
if isPrime(tmp):
print(tmp,end=',')
while True:
num = input('2이상의 숫자를 입력하세요:')
if no num.isnumeric():
continue
num = int(num)
if num<2:
continue
break
isprime = True
for n in range(2,num):
if num % n ==0:
isprime = False
break
if prime:
print('소수입니다.')
else:
print('소수가 아닙니다.')