4 replaced http://codegolf.stackexchange.com/ with https://codegolf.stackexchange.com/

In anticipation of MathJax being temporarily disabled, the rendered MathJax in this question has been replaced with images. You are still welcome to post answers but you'll have to view the rendered MathJax on another site.

PPCGPPCG just got MathJax! This means we can now easily include well formatted mathematical formulas into posts. (Handy MathJax tutorial.)

For example, here is the golden ratio expressed as an infinite continued fraction:

The MathJax code for this equation is

$$\varphi=1+\cfrac1{1+\cfrac1{1+\cfrac1{1+\cfrac1{1+\ddots}}}}$$

You can find this by right clicking the formula and following Show Math AsTeX Commands.

# Challenge

Write a program that takes in a non-negative integer, n, and outputs the MathJax code for that many "steps" of the continued fraction for the golden ratio.

To keep things standard across answers, you must use this exact MathJax syntax:

• For n = 0, the output must be $$\varphi=1+\dots$$.
Which is rendered as:

• For n = 1, the output must be $$\varphi=1+\cfrac1{1+\ddots}$$.
Which is rendered as:

• For n = 2, the output must be $$\varphi=1+\cfrac1{1+\cfrac1{1+\ddots}}$$.
Which is rendered as:

• For n = 3, the output must be $$\varphi=1+\cfrac1{1+\cfrac1{1+\cfrac1{1+\ddots}}}$$.
Which is rendered as:

This pattern continues on for larger n. You could say that n represents the number of division lines in the equation.

### Notes

• \cfrac is used instead of the more common \frac.
• \dots is used instead of \ddots for n = 0.
• Take input from stdin or the command line.
• Output to stdout (with an optional trailing newline).
• Alternatively, you may write a function that takes in n as an integer and returns the MathJax code as a string (or still prints it).

# Scoring

The smallest submission in bytes wins. Tiebreaker goes to the earlier submission.

In anticipation of MathJax being temporarily disabled, the rendered MathJax in this question has been replaced with images. You are still welcome to post answers but you'll have to view the rendered MathJax on another site.

PPCG just got MathJax! This means we can now easily include well formatted mathematical formulas into posts. (Handy MathJax tutorial.)

For example, here is the golden ratio expressed as an infinite continued fraction:

The MathJax code for this equation is

$$\varphi=1+\cfrac1{1+\cfrac1{1+\cfrac1{1+\cfrac1{1+\ddots}}}}$$

You can find this by right clicking the formula and following Show Math AsTeX Commands.
The $$ means it is displayed on its own in the center of the page instead of inline. Use a single  for inline. # Challenge Write a program that takes in a non-negative integer, n, and outputs the MathJax code for that many "steps" of the continued fraction for the golden ratio. To keep things standard across answers, you must use this exact MathJax syntax: • For n = 0, the output must be $$\varphi=1+\dots$$. Which is rendered as: • For n = 1, the output must be $$\varphi=1+\cfrac1{1+\ddots}$$. Which is rendered as: • For n = 2, the output must be $$\varphi=1+\cfrac1{1+\cfrac1{1+\ddots}}$$. Which is rendered as: • For n = 3, the output must be $$\varphi=1+\cfrac1{1+\cfrac1{1+\cfrac1{1+\ddots}}}$$. Which is rendered as: This pattern continues on for larger n. You could say that n represents the number of division lines in the equation. ### Notes • \cfrac is used instead of the more common \frac. • \dots is used instead of \ddots for n = 0. • Take input from stdin or the command line. • Output to stdout (with an optional trailing newline). • Alternatively, you may write a function that takes in n as an integer and returns the MathJax code as a string (or still prints it). # Scoring The smallest submission in bytes wins. Tiebreaker goes to the earlier submission. In anticipation of MathJax being temporarily disabled, the rendered MathJax in this question has been replaced with images. You are still welcome to post answers but you'll have to view the rendered MathJax on another site. PPCG just got MathJax! This means we can now easily include well formatted mathematical formulas into posts. (Handy MathJax tutorial.) For example, here is the golden ratio expressed as an infinite continued fraction: The MathJax code for this equation is $$\varphi=1+\cfrac1{1+\cfrac1{1+\cfrac1{1+\cfrac1{1+\ddots}}}}$$ You can find this by right clicking the formula and following Show Math AsTeX Commands. The $$ means it is displayed on its own in the center of the page instead of inline. Use a single $ for inline. # Challenge Write a program that takes in a non-negative integer, n, and outputs the MathJax code for that many "steps" of the continued fraction for the golden ratio. To keep things standard across answers, you must use this exact MathJax syntax: • For n = 0, the output must be $$\varphi=1+\dots$$. Which is rendered as: • For n = 1, the output must be $$\varphi=1+\cfrac1{1+\ddots}$$. Which is rendered as: • For n = 2, the output must be $$\varphi=1+\cfrac1{1+\cfrac1{1+\ddots}}$$. Which is rendered as: • For n = 3, the output must be $$\varphi=1+\cfrac1{1+\cfrac1{1+\cfrac1{1+\ddots}}}$$. Which is rendered as: This pattern continues on for larger n. You could say that n represents the number of division lines in the equation. ### Notes • \cfrac is used instead of the more common \frac. • \dots is used instead of \ddots for n = 0. • Take input from stdin or the command line. • Output to stdout (with an optional trailing newline). • Alternatively, you may write a function that takes in n as an integer and returns the MathJax code as a string (or still prints it). # Scoring The smallest submission in bytes wins. Tiebreaker goes to the earlier submission. 2 removed MathJax In anticipation of MathJax being temporarily disabled, the rendered MathJax in this question has been replaced with images. You are still welcome to post answers but you'll have to view the rendered MathJax on another site. PPCG just got MathJax! This means we can now easily include well formatted mathematical formulas into posts. (Handy MathJax tutorial.) For example, here is the golden ratio,$\varphi$, expressed as an infinite continued fraction: $$\varphi=1+\cfrac1{1+\cfrac1{1+\cfrac1{1+\cfrac1{1+\ddots}}}}$$ Write a program that takes in a non-negative integer,$n$n, and outputs the MathJax code for that many "steps" of the continued fraction for the golden ratio. • For$n=0$, the output must be $$\varphi=1+\dots$$. Which is rendered as: $$\varphi=1+\dots$$ For n = 0, the output must be $$\varphi=1+\dots$$. Which is rendered as: • For$n=1$, the output must be $$\varphi=1+\cfrac1{1+\ddots}$$. Which is rendered as: $$\varphi=1+\cfrac1{1+\ddots}$$ For n = 1, the output must be $$\varphi=1+\cfrac1{1+\ddots}$$. Which is rendered as: • For$n=2$, the output must be $$\varphi=1+\cfrac1{1+\cfrac1{1+\ddots}}$$. Which is rendered as: $$\varphi=1+\cfrac1{1+\cfrac1{1+\ddots}}$$ For n = 2, the output must be $$\varphi=1+\cfrac1{1+\cfrac1{1+\ddots}}$$. Which is rendered as: • For$n=3$, the output must be $$\varphi=1+\cfrac1{1+\cfrac1{1+\cfrac1{1+\ddots}}}$$. Which is rendered as: $$\varphi=1+\cfrac1{1+\cfrac1{1+\cfrac1{1+\ddots}}}$$ For n = 3, the output must be $$\varphi=1+\cfrac1{1+\cfrac1{1+\cfrac1{1+\ddots}}}$$. Which is rendered as: This pattern continues on for larger$n$n. You could say that$n$n represents the number of division lines in the equation. • \cfrac is used instead of the more common \frac. • \dots is used instead of \ddots for$n=0$n = 0. • Take input from stdin or the command line. • Output to stdout (with an optional trailing newline). • Alternatively, you may write a function that takes in$nn as an integer and returns the MathJax code as a string (or still prints it). Thanks to orlp, here's a handy byte counter stack snippet: <!DOCTYPE html><html><head><style type=text/css>html,body{margin:0;height:100%;overflow-y:hidden;font-family:'Helvetica Neue',Helvetica,Arial,sans-serif}#wrapper{overflow-y:hidden;margin:0;min-height:100%;padding:10px}#fileinput{display:none}#bytes,#chars{white-space:nowrap;font-weight:bold;font-size:20px;padding-right:10px}td{vertical-align:middle}table{margin-bottom:10px;margin-right:80px}#textinput{width:100%;box-sizing:border-box}</style><!--[if lte IE 6]><style type=text/css>#container{height:100%}</style><![endif]--></head><body><div id=wrapper><table><tr><td id=bytes>0 bytes</td><td rowspan=2>Drag and drop a file anywhere on this snippet, <a href=# id=fileselect>select a file using a dialog</a>, or enter UTF-8 code in the textbox.</td></tr><tr><td id=chars>0 chars</td></tr></table><input type=file id=fileinput onchange=handle_file(this.files)><textarea id=textinput onkeyup=textbox(this.value) onchange=textbox(this.value)></textarea></div><script src=https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js></script><script type=text/javascript>function nodefault(a){a.stopPropagation();a.preventDefault()}function handle_file(b){var a=new FileReader();a.onload=function(c){("#chars").text(a.result.length+" chars")};a.readAsText(b[0],"UTF-8");$("#bytes").text(b[0].size+" bytes")}function textbox(a){$("#bytes").text((new Blob([a],{encoding:"UTF-8",type:"text/plain;charset=UTF-8"})).size+" bytes");$("#chars").text(a.length+" chars")}function drop(a){nodefault(a);handle_file(a.dataTransfer.files)}function click(a){nodefault(a);$("#fileinput")[0].click()}$(document).ready(function(){var a=function(){$("#textinput").height($(window).height()-$("#textinput").offset().top-20)};$(window).resize(a);a()});document.body.addEventListener("dragenter",nodefault,false);document.body.addEventListener("dragover",nodefault,false);document.body.addEventListener("drop",drop,false);$("#fileselect").on("click",click);</script></body></html>

PPCG just got MathJax! This means we can now easily include well formatted mathematical formulas into posts. (Handy MathJax tutorial.)

For example, here is the golden ratio, $\varphi$, expressed as an infinite continued fraction:

$$\varphi=1+\cfrac1{1+\cfrac1{1+\cfrac1{1+\cfrac1{1+\ddots}}}}$$

Write a program that takes in a non-negative integer, $n$, and outputs the MathJax code for that many "steps" of the continued fraction for the golden ratio.

• For $n=0$, the output must be $$\varphi=1+\dots$$.
Which is rendered as: $$\varphi=1+\dots$$
• For $n=1$, the output must be $$\varphi=1+\cfrac1{1+\ddots}$$.
Which is rendered as: $$\varphi=1+\cfrac1{1+\ddots}$$
• For $n=2$, the output must be $$\varphi=1+\cfrac1{1+\cfrac1{1+\ddots}}$$.
Which is rendered as: $$\varphi=1+\cfrac1{1+\cfrac1{1+\ddots}}$$
• For $n=3$, the output must be $$\varphi=1+\cfrac1{1+\cfrac1{1+\cfrac1{1+\ddots}}}$$.
Which is rendered as: $$\varphi=1+\cfrac1{1+\cfrac1{1+\cfrac1{1+\ddots}}}$$

This pattern continues on for larger $n$. You could say that $n$ represents the number of division lines in the equation.

• \cfrac is used instead of the more common \frac.
• \dots is used instead of \ddots for $n=0$.
• Take input from stdin or the command line.
• Output to stdout (with an optional trailing newline).
• Alternatively, you may write a function that takes in $n$ as an integer and returns the MathJax code as a string (or still prints it).

Thanks to orlp, here's a handy byte counter stack snippet:

<!DOCTYPE html><html><head><style type=text/css>html,body{margin:0;height:100%;overflow-y:hidden;font-family:'Helvetica Neue',Helvetica,Arial,sans-serif}#wrapper{overflow-y:hidden;margin:0;min-height:100%;padding:10px}#fileinput{display:none}#bytes,#chars{white-space:nowrap;font-weight:bold;font-size:20px;padding-right:10px}td{vertical-align:middle}table{margin-bottom:10px;margin-right:80px}#textinput{width:100%;box-sizing:border-box}</style><!--[if lte IE 6]><style type=text/css>#container{height:100%}</style><![endif]--></head><body><div id=wrapper><table><tr><td id=bytes>0 bytes</td><td rowspan=2>Drag and drop a file anywhere on this snippet, <a href=# id=fileselect>select a file using a dialog</a>, or enter UTF-8 code in the textbox.</td></tr><tr><td id=chars>0 chars</td></tr></table><input type=file id=fileinput onchange=handle_file(this.files)><textarea id=textinput onkeyup=textbox(this.value) onchange=textbox(this.value)></textarea></div><script src=https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js></script><script type=text/javascript>function nodefault(a){a.stopPropagation();a.preventDefault()}function handle_file(b){var a=new FileReader();a.onload=function(c){$("#chars").text(a.result.length+" chars")};a.readAsText(b[0],"UTF-8");$("#bytes").text(b[0].size+" bytes")}function textbox(a){$("#bytes").text((new Blob([a],{encoding:"UTF-8",type:"text/plain;charset=UTF-8"})).size+" bytes");$("#chars").text(a.length+" chars")}function drop(a){nodefault(a);handle_file(a.dataTransfer.files)}function click(a){nodefault(a);$("#fileinput")[0].click()}$(document).ready(function(){var a=function(){$("#textinput").height($(window).height()-$("#textinput").offset().top-20)};$(window).resize(a);a()});document.body.addEventListener("dragenter",nodefault,false);document.body.addEventListener("dragover",nodefault,false);document.body.addEventListener("drop",drop,false);\$("#fileselect").on("click",click);</script></body></html>

In anticipation of MathJax being temporarily disabled, the rendered MathJax in this question has been replaced with images. You are still welcome to post answers but you'll have to view the rendered MathJax on another site.

PPCG just got MathJax! This means we can now easily include well formatted mathematical formulas into posts. (Handy MathJax tutorial.)

For example, here is the golden ratio expressed as an infinite continued fraction:

Write a program that takes in a non-negative integer, n, and outputs the MathJax code for that many "steps" of the continued fraction for the golden ratio.

• For n = 0, the output must be $$\varphi=1+\dots$$.
Which is rendered as:

• For n = 1, the output must be $$\varphi=1+\cfrac1{1+\ddots}$$.
Which is rendered as:

• For n = 2, the output must be $$\varphi=1+\cfrac1{1+\cfrac1{1+\ddots}}$$.
Which is rendered as:

• For n = 3, the output must be $$\varphi=1+\cfrac1{1+\cfrac1{1+\cfrac1{1+\ddots}}}$$.
Which is rendered as:

This pattern continues on for larger n. You could say that n represents the number of division lines in the equation.

• \cfrac is used instead of the more common \frac.
• \dots is used instead of \ddots for n = 0.
• Take input from stdin or the command line.
• Output to stdout (with an optional trailing newline).
• Alternatively, you may write a function that takes in n as an integer and returns the MathJax code as a string (or still prints it).