-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from INIT-Algorithm/yoojin
#2 : Week1_유진이티
- Loading branch information
Showing
2 changed files
with
25 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
from itertools import combinations #itertools의 combinations 함수 | ||
|
||
n,m = map(int, input().split()) # N과 M 입력받기 | ||
|
||
a = [] # [1,2,3,4 ..] | ||
for i in range(1,n+1): | ||
a.append(i) | ||
|
||
for i in combinations(a,m): # a에서 원소 개수 m개인 조합을 뽑는 것, 출력 | ||
for j in i: | ||
print(j,end=' ') | ||
print() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
n = int(input()) # 수의 개수 N 입력 받기 | ||
numbers = map(int, input().split()) # N개의 수 입력 받기 | ||
count = 0 # 소수의 개수를 세기 위한 변수 count 초기화 | ||
|
||
for num in numbers: | ||
a = 0 | ||
if num > 1 : | ||
for i in range(2, num): # 2부터 (num-1)까지 (자기자신 제외) | ||
if num % i == 0: | ||
a += 1 # 2와 (num-1) 사이 숫자로 나누어 떨어지면 a 1씩 증가 | ||
if a == 0: | ||
count += 1 # a == 0 이면 소수이므로 count 1씩 증가 | ||
print(count) |