A Pen by wanfeichao

Thumbnail
This awesome code was written by 0xfc, you can see more from this user in the personal repository.
You can find the original code on Codepen.io
Copyright 0xfc ©
  • HTML
  • JavaScript
<!DOCTYPE html>
<html lang="en" >

<head>
  <meta charset="UTF-8">
  <title>A Pen by  wanfeichao</title>
  
  
  
  
  
</head>

<body>

  
  
  

    <script  src="js/index.js"></script>




</body>

</html>

/*Downloaded from https://www.codeseek.co/0xfc/a-pen-by-wanfeichao-ZoKjXv */
function a(n) {
  if (n === 1) {
    return [1];
  }
  if (n === 2) {
    return [1, 1];
  }
  
  const r = a(--n);
  const temp = [];
  for(let i = 0; i < r.length - 1; i++) {
    temp.push(r[i] + r[i+1]);
  }
  return [1].concat(temp).concat([1]);
}

a(3);

Comments