Last active
January 6, 2026 02:24
-
-
Save kms0219kms/38e373172d1fa44436af06f366a29a56 to your computer and use it in GitHub Desktop.
2025-2026 오성고_공동교육_정보과학 Day 2 (피보나치 수열)
This file contains hidden or 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
| def main(): | |
| n = int(input("Number of Fibonacci numbers to generate: ")) | |
| for i in range(n): | |
| print(f"{i+1}: {fibonachi(i)}") | |
| def fibonachi(n: int) -> int: | |
| return n if n <= 1 else fibonachi(n-1) + fibonachi(n-2) | |
| if __name__ == "__main__": | |
| main() |
This file contains hidden or 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
| def main(): | |
| n = int(input("Number of Fibonacci numbers to generate: ")) | |
| for i in range(n): | |
| print(f"{i+1}: {fibonachi_loop(i)}") | |
| def fibonachi_loop(n: int) -> int: | |
| a, b = 0, 1 | |
| for _ in range(n): | |
| a, b = b, a + b | |
| return a | |
| if __name__ == "__main__": | |
| main() |
This file contains hidden or 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
| def main(): | |
| n = int(input("Please type a number: ")) | |
| print(fibonachi_loop(n)) | |
| def fibonachi_loop(n: int) -> int: | |
| a, b = 0, 1 | |
| for _ in range(n): | |
| a, b = b, a + b | |
| return a | |
| if __name__ == "__main__": | |
| main() |
This file contains hidden or 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
| def main(): | |
| n = int(input("Please type a number: ")) | |
| print(fibonachi(n)) | |
| def fibonachi(n: int) -> int: | |
| return n if n <= 1 else fibonachi(n-1) + fibonachi(n-2) | |
| if __name__ == "__main__": | |
| main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment