Discussion
Loading...

Post

  • About
  • Code of conduct
  • Privacy
  • Users
  • Instances
  • About Bonfire
Jak2k 馃嚜馃嚭
@jak2k@mastodontech.de  路  activity timestamp yesterday

This is how you properly calculate an element from the Fibonacci sequence in JavaScript:

function fibonacci(n) {
const phi = (1+Math.sqrt(5))/2;
return Math.round((phi**(n) - (-phi)**(-n))/(2*phi-1));
}

fibonacci(1000)

This is much faster than your recursive Rust solution! That means JS is faster than Rust!

#rust #javascript

  • Copy link
  • Flag this post
  • Block
Log in

bonfire.cafe

A space for Bonfire maintainers and contributors to communicate

bonfire.cafe: About 路 Code of conduct 路 Privacy 路 Users 路 Instances
Bonfire social 路 1.0.0-rc.3.21 no JS en
Automatic federation enabled
  • Explore
  • About
  • Members
  • Code of Conduct
Home
Login