Hacker News new | past | comments | ask | show | jobs | submit login
Show HN: Math Puzzle
1 point by lordmax 10 days ago | hide | past | favorite | discuss
Paste 'big.js' [1] into your web console. Run the following code - can you figure out WHY it works and what it represents?

  let printN = (maxN) => {
   let nextVal = (x,n) => { 
    let b2 = new Big(2);
    let val = b2.pow(n).mul(3).mul(b2.minus(x).sqrt());
    console.log(val.toString()); 
    return x.plus(2).sqrt(); 
  };

  let s = (new Big(3)).sqrt().plus(2).sqrt();
  for (let n=2; n<maxN; n++) { 
    Big.DP = n + 10;  
    s = nextVal(s,n); }
  };
  printN(500);
[1] Big decimal: https://raw.githubusercontent.com/MikeMcl/big.js/master/big.min.js

[2] Try on JSFiddle: https://jsfiddle.net/asgxL84y/

[3] The math: https://pasteboard.co/JeNGeB0.png






Guidelines | FAQ | Support | API | Security | Lists | Bookmarklet | Legal | Apply to YC | Contact

Search: