Skip to content

Commit

Permalink
2023-03-29 소수 & 팰린드롬
Browse files Browse the repository at this point in the history
  • Loading branch information
suhyun113 committed Mar 29, 2024
1 parent 8b54ef2 commit e8504f5
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
22 changes: 22 additions & 0 deletions suhyun113/2-suhyun113.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# 팰린드롬 수
def is_palindrome(num):
return str(num) == str(num)[::-1]

# 소수 찾기
def is_prime_num(n):
if n < 2:
return False # 1은 소수가 아님
for i in range(2, int(n**0.5) + 1):
if n % i == 0:
return False
return True

N = int(input()) # 어떤 수 N
# output은 N보다 크거나 같으므로 N으로 초기화
result = N # 현재

while True: # N보다 크거나 같은 수(항상)
if is_prime_num(result) and is_palindrome(result): # 소수이면서 팰린드롬인 수
print(result)
break
result += 1
4 changes: 2 additions & 2 deletions suhyun113/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@

| 차시 | 날짜 | 문제유형 | 링크 | 풀이 |
|:----:|:---------:|:----:|:-----:|:----:|
| 1차시 | 2024.02.12 | DP | [평범한 배낭](https://www.acmicpc.net/problem/12865) | [#1](https://github.com/AlgoLeadMe/AlgoLeadMe-7/pull/5) |
---
| 1차시 | 2024.03.25 | 그리디 | [체육복](https://school.programmers.co.kr/learn/courses/30/lessons/42862) | [#1](https://github.com/AlgoLeadMe/AlgoLeadMe-10/pull/2) |
| 2차시 | 2024.03.29 | 수학 | [소수 & 팰린드롬](https://www.acmicpc.net/problem/1747) | [#1](https://github.com/AlgoLeadMe-10/AlgoLeadMe-10/pull/3) |

0 comments on commit e8504f5

Please sign in to comment.