Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
Tags
- git
- SQL
- Javascript
- DBMS
- docker
- MariaDB
- IntelliJ
- java
- 리눅스
- rsync
- mssql
- group by
- mysql
- analytics4
- oracle
- MongoDB
- Python
- 자바
- top
- 명령어
- spring
- API
- JPA
- 오블완
- 티스토리챌린지
- network
- 트랜잭션
- Linux
- PostgreSQL
- 차이점
Archives
- Today
- Total
hanker
백준(10870) JAVA - 피보나치 수 5 본문
반응형
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int tmp = 0;
int befNum = 1, aftNum = 1;
if(n == 1 || n == 2){
tmp = 1;
} else {
for(int i = 3 ; i <= n ; i++){
tmp = befNum + aftNum;
befNum = aftNum;
aftNum = tmp;
}
}
System.out.println(tmp);
}
}
반응형
'Study > ALGORITHM' 카테고리의 다른 글
백준(11729) JAVA - 하노이 탑 이동 순서 (0) | 2021.09.07 |
---|---|
백준(2447) JAVA - 별 찍기 - 10 (0) | 2021.08.23 |
백준(10872) JAVA - 팩토리얼 (0) | 2021.07.09 |
백준(1002) JAVA - 터렛 (0) | 2021.07.07 |
백준(3053) JAVA - 택시 기하학 (0) | 2021.07.07 |