일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | 7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | 27 | 28 |
29 | 30 |
Tags
- 목록
- codingtest
- html
- 시큐리티
- 스프링 부트
- 시큐리티로그인
- 시큐리티 로그인
- 프로그래머스
- 반복문
- springboot
- Linux
- css
- 코딩테스트
- java
- JAVA11
- security
- 소스트리
- StyleSheet
- 2차원배열
- input태그
- sql
- javascript
- gradle
- 리눅스
- programmers
- Spring boot
- 싱글톤
- 로그인
- 시큐리티 로그아웃
- springSecurity
Archives
- Today
- Total
JAVAIARY
프로그래머스) 약수 구하기 본문
문제: https://school.programmers.co.kr/learn/courses/30/lessons/120897
프로그래머스
코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.
programmers.co.kr
import java.util.ArrayList;
import java.util.Collections;
public class FindingDividors {
public ArrayList<Integer> solution(int n) {
ArrayList<Integer> answer = new ArrayList<>();
answer.add(1);
if (n != 1) {
answer.add(n);
}
for (int i = n / 2; i > 1; i--) {
if (n % i == 0) {
answer.add(i);
}
}
Collections.sort(answer);
return answer;
}
}
- 더 좋은 방법이 떠오르지 않았다...
'examplePractice' 카테고리의 다른 글
프로그래머스) OX 퀴즈 (0) | 2023.03.21 |
---|---|
프로그래머스) H-Index (0) | 2023.03.04 |
프로그래머스) 연속된 수의 합 (0) | 2023.02.28 |
프로그래머스) 구명보트 (0) | 2023.02.26 |
프로그래머스) 둘만의 암호 (0) | 2023.02.25 |