Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/omega-rosetta/blob/main/drafts/rosettacode/fibonacci-n-step-number-sequences.wiki # omega-rosetta aien-dev/omega-rosetta Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `omega-rosetta / drafts / rosettacode / fibonacci-n-step-number-sequences.wiki` 104 lines ยท 2317 bytes Raw Blame History 1 =={{header|Omegese}}== 2 {{works with|omc|sha256 `2c824805`, aien-dev/omega-mv `e5b32567`, Linux AArch64}} 3 Omega has no imports, so the small output helpers (emit and friends) are part of the program. 4 5 om2 6 text nl "\n" 7 text sp " " 8 text t2 "fibonacci: " 9 text t3 "tribonacci:" 10 text t4 "tetranacci:" 11 text t5 "pentanacci:" 12 text t6 "hexanacci: " 13 text t7 "heptanacci:" 14 text t8 "octonacci: " 15 text t9 "nonanacci: " 16 text t10 "decanacci: " 17 text tl "lucas: " 18 note emit writes every byte of a to stdout; a short write is retried, an error exits 1 19 fn emit a view uchar * to void 20 o = ulong 0 21 while lt o len a bound 4096 22 k = write 1 a o sub len a o 23 if le k 0 24 exit 1 25 end 26 o = add o ulong k 27 end 28 end 29 note emitu writes n in decimal; 20 digits hold every ulong 30 fn emitu n ulong to void 31 d = new uchar 20 0 32 i = ulong 20 33 v = n 34 while true bound 20 35 i = sub i 1 36 put d i uchar add rem v 10 48 37 v = div v 10 38 if eq v 0 39 break 40 end 41 end 42 emit part d i sub 20 i 43 end 44 note the n-step sequence starts 1, 1, 2, 4, ..., 2^(n-2) (the n-step seeds) and then each term sums the 45 note previous n; the Lucas numbers are the 2-step sequence seeded 2, 1. 15 terms, all below 2^15 * 15 46 fn seq n ulong s0 ulong s1 ulong to void 47 a = new ulong 15 0 48 put a 0 s0 49 put a 1 s1 50 for i ulong 13 51 k = add i 2 52 s = ulong 0 53 if le k sub n 1 54 s = shl ulong 1 sub k 1 55 else 56 for j ulong n 57 s = add s get a sub sub k 1 j 58 end 59 end 60 put a k s 61 end 62 for i ulong 15 63 emit sp 64 emitu get a i 65 end 66 emit nl 67 end 68 fn main to int 69 emit t2 70 seq 2 1 1 71 emit t3 72 seq 3 1 1 73 emit t4 74 seq 4 1 1 75 emit t5 76 seq 5 1 1 77 emit t6 78 seq 6 1 1 79 emit t7 80 seq 7 1 1 81 emit t8 82 seq 8 1 1 83 emit t9 84 seq 9 1 1 85 emit t10 86 seq 10 1 1 87 emit tl 88 seq 2 2 1 89 ret 0 90 end 91 92 {{out}} 93

94 fibonacci: 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610

95 tribonacci: 1 1 2 4 7 13 24 44 81 149 274 504 927 1705 3136

96 tetranacci: 1 1 2 4 8 15 29 56 108 208 401 773 1490 2872 5536

97 pentanacci: 1 1 2 4 8 16 31 61 120 236 464 912 1793 3525 6930

98 hexanacci: 1 1 2 4 8 16 32 63 125 248 492 976 1936 3840 7617

99 heptanacci: 1 1 2 4 8 16 32 64 127 253 504 1004 2000 3984 7936

100 octonacci: 1 1 2 4 8 16 32 64 128 255 509 1016 2028 4048 8080

101 nonanacci: 1 1 2 4 8 16 32 64 128 256 511 1021 2040 4076 8144

102 decanacci: 1 1 2 4 8 16 32 64 128 256 512 1023 2045 4088 8172

103 lucas: 2 1 3 4 7 11 18 29 47 76 123 199 322 521 843

104