Skip to main content
3 of 10
added 410 characters in body
user avatar
user avatar

#JavaScript, 114 bytes

This is my first entry in a codegolf contest! Please tell me how to improve.

x="repeat";y=n=>{return a=!n?"$$\\varphi=1+\\dots$$":"$$\\varphi="+"1+\\cfrac1{"[x](n)+"1+\\ddots"+"}"[x](n)+"$$"}

Paste into browser console and call as f(n) where n is the number of 'steps'.

Simplified code:

var x = "repeat";
function y(n) {
   if(n === 0) {
      return "$$\\varphi=1+\\dots$$";
   } else {
      return "$$\\varphi=" + "1+\\cfrac1{".repeat(n) + "1+\\ddots"+"}".repeat(n)+"$$";
   } //                                   ^in golfed version, String.repeat(n) 
    //                                     is called as String[x](n)
}
user31556