We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 8c0fe9b commit 0753719Copy full SHA for 0753719
Hongjoo/lv2/소수찾기.py
@@ -0,0 +1,30 @@
1
+from itertools import permutations
2
+def isPrime(n):
3
+ if n <= 1 :
4
+ return False
5
+
6
+ end = int(n**(1/2))
7
+ for i in range(2,end+1):
8
+ if n% i == 0 :
9
10
+ return True
11
12
+def solution(numbers):
13
+ count = 0
14
15
+ arrnum= set() # 중복 방지
16
+ #1. 문자열 분리하기 -> 리스트[] 에 넣기
17
+ li = list(numbers)
18
+ # 분리된 숫자들을 "순열 조합"
19
+ for i in range(1,len(numbers)+1) :
20
+ p_arr =permutations(li,i)
21
+ for perm in p_arr :
22
+ num = int("".join(perm))
23
+ arrnum.add(num)
24
+ print( arrnum)
25
+ #prime 확인
26
+ for n in arrnum:
27
+ if isPrime(n) :
28
+ count+= 1
29
+ return count
30
0 commit comments