π 2023λ 12μ 18μΌ
[java 10μΌμ°¨]
μ§μμ¬μ λλ¬Έμ κΈνκ² ν΄κ°μ¬μ©ν λ μ΄λ€.
λ° μ 리λ΄μ©μ κ°μ κ΅μ‘μμκ² λ°μ λ°λ‘ μ 리νλ€.
λ©μλκ° μκΈ°μμ μ νΈμΆνλ λ©μλλ₯Ό μ¬κ·ν¨μλΌ νλ€. μ΄λ¬ν νΈμΆλ°©μμ μ¬κ·νΈμΆμ΄λΌκ³ νλ€.
int[] fibonacchi1 = new int [10]; int first = 1; int second = 1; for(int i = 2; i < 10; i++){ int third = first + second; first = second; second = third; System.out.print(third + " "); } System.out.println(fibonacci(10));
static int fibonacci (int n){ if(n <= 1){ return 1; } else{ return fibonacci(n-1) + fibonacci(n-2); } }
static void combination( List<Integer> myList1 , List<List<Integer>> combinations1, List<Integer> temp1, int n, int start ){ if(temp1.size() == n){ combinations1.add(new ArrayList<>(temp1)); return; } for (int i = start; i < myList1.size(); i++) { temp1.add(myList1.get(i)); combination(myList1, combinations1, temp1, n, i+1); temp1.remove(temp1.size()-1); } }