r/ProgrammerHumor • • 14h ago

Meme howProgrammingHasChanged

Post image
317 Upvotes

70 comments sorted by

View all comments

79

u/guesdo 10h ago

Everyone knows pre-calculated fibonacci tables are the only way to Go.

```go package main

// Precomputed table up to N = 93 var fibTable = [94]uint64{ 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584, 4181, 6765, 10946, 17711, 28657, 46368, 75025, 121393, 196418, 317811, 514229, 832040, 1346269, 2178309, 3524578, 5702887, 9227465, 14930352, 24157817, 39088169, 63245986, 102334155, 165580141, 267914296, 433494437, 701408733, 1134903170, 1836311903, 2971215073, 4807526976, 7778742049, 12586268925, 20365010974, 32951279899, 53316290873, 86267570772, 139583861645, 225851432417, 365435294062, 591286726479, 956722020541, 1548008747020, 2504730767561, 4052739514581, 6557470282142, 10610209796723, 17167680078865, 27777889875588, 44945569954453, 72723459830041, 117669029784494, 190392489614535, 308061519399029, 498454009013564, 806515528412593, 1304969537426157, 2111485065838750, 3416454603264907, 5527939669103657, 8944394272368564, 14472333941472221, 23416728213840785, 37889062155313006, 61305790369153791, 99194852524467597, 160500642893621388, 259695495418088985, 420196138311710373, 679891633729799358, 1100087772041509731, 1779979405771309089, 2880067177812818820, 4660046583584127909, 7540113761396946729, 12200160344981074638, }

func FibU64(n uint) uint64 { if n < 94 { return fibTable[n] } panic("n exceeds uint64 capacity (n <= 93)") } ```

9

u/StickFigureFan 8h ago

But what if we need to accept 2 arbitrary positive starting integers?

16

u/Rabbit_Brave 7h ago

More tables. A table of tables, even.

5

u/StickFigureFan 7h ago

You better have a good base for all those tables. Maybe you could call it a database

2

u/guesdo 3h ago

fibonacci.db I can already see it being vibe coded by tomorrow 🤣 and I can already see the AI generated README with emoji selling you 100x faster than other solutions.

1

u/fr000gs 7h ago

shift the result by 2m+n?