Skip to main content
added 28 characters in body
Source Link
user31556
user31556

#JavaScript, 114 109 106106 85 bytes thanks to George Reith

f=n=>'$$\\varphi=1+\\'+((x='cfrac1{1+\\'.repeat(n))&&x+'d')+'dots'+'}'.repeat(n)+'$$'

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

Previous entry (106 bytes) after removing false optimisation (thanks edc65!):

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

Previous entry (109 bytes):

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

Previous entry (114 bytes):

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:

function y(n) {
   if(n === 0) {
      return "$$\\varphi=1+\\dots$$";
   } else {
      return "$$\\varphi=" + "1+\\cfrac1{".repeat(n) + "1+\\ddots"+"}".repeat(n)+"$$";
   }

#JavaScript, 114 109 106 bytes

This is my first entry in a codegolf contest! Please tell me how to improve. Current entry (106 bytes) after removing false optimisation (thanks edc65!)

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

Previous entry (109 bytes):

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

Previous entry (114 bytes):

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:

function y(n) {
   if(n === 0) {
      return "$$\\varphi=1+\\dots$$";
   } else {
      return "$$\\varphi=" + "1+\\cfrac1{".repeat(n) + "1+\\ddots"+"}".repeat(n)+"$$";
   }

#JavaScript, 114 109 106 85 bytes thanks to George Reith

f=n=>'$$\\varphi=1+\\'+((x='cfrac1{1+\\'.repeat(n))&&x+'d')+'dots'+'}'.repeat(n)+'$$'

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

Previous entry (106 bytes):

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

Previous entry (109 bytes):

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

Previous entry (114 bytes):

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:

function y(n) {
   if(n === 0) {
      return "$$\\varphi=1+\\dots$$";
   } else {
      return "$$\\varphi=" + "1+\\cfrac1{".repeat(n) + "1+\\ddots"+"}".repeat(n)+"$$";
   }
removed MathJax since it is being disabled temporarily
Source Link
Calvin's Hobbies
  • 90k
  • 46
  • 339
  • 555

#JavaScript, 114 109 106 bytes

This is my first entry in a codegolf contest! Please tell me how to improve. Current entry (106 bytes) after removing false optimisation (thanks edc65!)

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

Previous entry (109 bytes):

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

Previous entry (114 bytes):

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:

function y(n) {
   if(n === 0) {
      return "$$\\varphi=1+\\dots$$";
   } else {
      return "$$\\varphi=" + "1+\\cfrac1{".repeat(n) + "1+\\ddots"+"}".repeat(n)+"$$";
   }
}

Returns:

  • n=0: $$\varphi=1+\dots$$
  • n=1: $$\varphi=1+\cfrac1{1+\ddots}$$
  • n=2: $$\varphi=1+\cfrac1{1+\cfrac1{1+\ddots}}$$
  • n=3: $$\varphi=1+\cfrac1{1+\cfrac1{1+\cfrac1{1+\ddots}}}$$

#JavaScript, 114 109 106 bytes

This is my first entry in a codegolf contest! Please tell me how to improve. Current entry (106 bytes) after removing false optimisation (thanks edc65!)

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

Previous entry (109 bytes):

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

Previous entry (114 bytes):

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:

function y(n) {
   if(n === 0) {
      return "$$\\varphi=1+\\dots$$";
   } else {
      return "$$\\varphi=" + "1+\\cfrac1{".repeat(n) + "1+\\ddots"+"}".repeat(n)+"$$";
   }
}

Returns:

  • n=0: $$\varphi=1+\dots$$
  • n=1: $$\varphi=1+\cfrac1{1+\ddots}$$
  • n=2: $$\varphi=1+\cfrac1{1+\cfrac1{1+\ddots}}$$
  • n=3: $$\varphi=1+\cfrac1{1+\cfrac1{1+\cfrac1{1+\ddots}}}$$

#JavaScript, 114 109 106 bytes

This is my first entry in a codegolf contest! Please tell me how to improve. Current entry (106 bytes) after removing false optimisation (thanks edc65!)

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

Previous entry (109 bytes):

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

Previous entry (114 bytes):

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:

function y(n) {
   if(n === 0) {
      return "$$\\varphi=1+\\dots$$";
   } else {
      return "$$\\varphi=" + "1+\\cfrac1{".repeat(n) + "1+\\ddots"+"}".repeat(n)+"$$";
   }
removed LaTeX in preparation of disabling MathJax
Source Link
Martin Ender
  • 197.2k
  • 67
  • 447
  • 975

#JavaScript, 114 109 106 bytes

This is my first entry in a codegolf contest! Please tell me how to improve. Current entry (106 bytes) after removing false optimisation (thanks edc65!)

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

Previous entry (109 bytes):

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

Previous entry (114 bytes):

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:

function y(n) {
   if(n === 0) {
      return "$$\\varphi=1+\\dots$$";
   } else {
      return "$$\\varphi=" + "1+\\cfrac1{".repeat(n) + "1+\\ddots"+"}".repeat(n)+"$$";
   }
}

Returns:

  • $n=0$n=0: $$\varphi=1+\dots$$ which renders as: $$\varphi=1+\dots$$
  • $n=1$n=1: $$\varphi=1+\cfrac1{1+\ddots}$$ which renders as: $$\varphi=1+\cfrac1{1+\ddots}$$
  • $n=2$n=2: $$\varphi=1+\cfrac1{1+\cfrac1{1+\ddots}}$$ which renders as: $$\varphi=1+\cfrac1{1+\cfrac1{1+\ddots}}$$
  • $n=3$n=3: $$\varphi=1+\cfrac1{1+\cfrac1{1+\cfrac1{1+\ddots}}}$$ which renders as: $$\varphi=1+\cfrac1{1+\cfrac1{1+\cfrac1{1+\ddots}}}$$

#JavaScript, 114 109 106 bytes

This is my first entry in a codegolf contest! Please tell me how to improve. Current entry (106 bytes) after removing false optimisation (thanks edc65!)

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

Previous entry (109 bytes):

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

Previous entry (114 bytes):

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:

function y(n) {
   if(n === 0) {
      return "$$\\varphi=1+\\dots$$";
   } else {
      return "$$\\varphi=" + "1+\\cfrac1{".repeat(n) + "1+\\ddots"+"}".repeat(n)+"$$";
   }
}

Returns:

  • $n=0$: $$\varphi=1+\dots$$ which renders as: $$\varphi=1+\dots$$
  • $n=1$: $$\varphi=1+\cfrac1{1+\ddots}$$ which renders as: $$\varphi=1+\cfrac1{1+\ddots}$$
  • $n=2$: $$\varphi=1+\cfrac1{1+\cfrac1{1+\ddots}}$$ which renders as: $$\varphi=1+\cfrac1{1+\cfrac1{1+\ddots}}$$
  • $n=3$: $$\varphi=1+\cfrac1{1+\cfrac1{1+\cfrac1{1+\ddots}}}$$ which renders as: $$\varphi=1+\cfrac1{1+\cfrac1{1+\cfrac1{1+\ddots}}}$$

#JavaScript, 114 109 106 bytes

This is my first entry in a codegolf contest! Please tell me how to improve. Current entry (106 bytes) after removing false optimisation (thanks edc65!)

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

Previous entry (109 bytes):

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

Previous entry (114 bytes):

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:

function y(n) {
   if(n === 0) {
      return "$$\\varphi=1+\\dots$$";
   } else {
      return "$$\\varphi=" + "1+\\cfrac1{".repeat(n) + "1+\\ddots"+"}".repeat(n)+"$$";
   }
}

Returns:

  • n=0: $$\varphi=1+\dots$$
  • n=1: $$\varphi=1+\cfrac1{1+\ddots}$$
  • n=2: $$\varphi=1+\cfrac1{1+\cfrac1{1+\ddots}}$$
  • n=3: $$\varphi=1+\cfrac1{1+\cfrac1{1+\cfrac1{1+\ddots}}}$$
deleted 3 characters in body
Source Link
user31556
user31556
Loading
added 12 characters in body
Source Link
user31556
user31556
Loading
added 138 characters in body
Source Link
user31556
user31556
Loading
added 410 characters in body
Source Link
user31556
user31556
Loading
added 410 characters in body
Source Link
user31556
user31556
Loading
added 31 characters in body
Source Link
user31556
user31556
Loading
Source Link
user31556
user31556
Loading