Fibonacci Sequence
The Fibonacci sequence is a sequence where the first two terms are 1, and each subsequent term is the sum of the two preceding terms.
text
1, 1, 2, 3, 5, 8, 13, 21, 34, 55, ...This example reads N from standard input and prints the first N terms, one per line.
Code
junlang
오ㅋ준ㅋ서ㅋ~준서!!!!!ㅋ
오?~준서!ㅋ
오~준서!!ㅋ
오?~준서!!!!ㅋ
준서야 !!!!ㅁ!!!!! 또처먹냐?
오준서!!ㅋ
!~!!~준서!!!ㅋ
!!~준서!ㅋ
!!!~준서!!ㅋ
!!!!~오~준서!!!!ㅋ
ㅋVariables
| Variable | Meaning |
|---|---|
! | Previous term (a) |
!! | Current term (b) |
!!! | Temporary value for computing the next term (c) |
!!!! | Loop counter (i) |
!!!!! | Number of terms to print (N) |
How It Works
- Read N from input and store it in
!!!!!. - Initialize
ato 0 andbto 1. - While
iis less than N, repeat:- Print the current value
b. - Compute
c = a + b. - Shift one step: assign
btoaandctob. - Increment
iby 1.
- Print the current value
Execution Example
If the input is 오오오오오오오 (7), the output is:
text
오
오
오오
오오오
오오오오오
오오오오오오오오
오 오오오Each line represents 1, 1, 2, 3, 5, 8, and 13 respectively.