Skip to main content
deleted 57 characters in body; edited tags
Source Link

The continued fraction of a number n\$n\$ is a fraction of the following form:
 

which

$$a_0 + \cfrac 1 {a_1 + \cfrac 1 {a_2 + \cfrac 1 {a_3 + \cfrac 1 {a_4 + \ddots}}}}$$

which converges to n\$n\$.

The sequence a\$a\$ in a continued fraction is typically written as: [a0; a1, a2, a3, ... an]\$[a_0; a_1, a_2, a_3, ... a_n]\$.
We will write ours in the same fashion, but with the repeating part between semicolons.

Your goal is to return the continued fraction of the square root of n\$n\$.
  

Input: An integer, n\$n\$. n\$n\$ will never be a perfect square.
Output: The continued fraction of sqrt(n)\$\sqrt n\$.

Test Cases:
2 -> [1; 2;]
3 -> [1; 1, 2;]
19 -> [4; 2, 1, 3, 1, 2, 8;]

Shortest code wins. Good luck!

The continued fraction of a number n is a fraction of the following form:
 

which converges to n.

The sequence a in a continued fraction is typically written as: [a0; a1, a2, a3, ... an].
We will write ours in the same fashion, but with the repeating part between semicolons.

Your goal is to return the continued fraction of the square root of n.
 Input: An integer, n. n will never be a perfect square.
Output: The continued fraction of sqrt(n).

Test Cases:
2 -> [1; 2;]
3 -> [1; 1, 2;]
19 -> [4; 2, 1, 3, 1, 2, 8;]

Shortest code wins. Good luck!

The continued fraction of a number \$n\$ is a fraction of the following form:

$$a_0 + \cfrac 1 {a_1 + \cfrac 1 {a_2 + \cfrac 1 {a_3 + \cfrac 1 {a_4 + \ddots}}}}$$

which converges to \$n\$.

The sequence \$a\$ in a continued fraction is typically written as: \$[a_0; a_1, a_2, a_3, ... a_n]\$.
We will write ours in the same fashion, but with the repeating part between semicolons.

Your goal is to return the continued fraction of the square root of \$n\$. 

Input: An integer, \$n\$. \$n\$ will never be a perfect square.
Output: The continued fraction of \$\sqrt n\$.

Test Cases:
2 -> [1; 2;]
3 -> [1; 1, 2;]
19 -> [4; 2, 1, 3, 1, 2, 8;]

Shortest code wins. Good luck!

replaced http://upload.wikimedia.org/ with https://upload.wikimedia.org/
Source Link

The continued fraction of a number n is a fraction of the following form:

http://upload.wikimedia.org/wikipedia/en/math/1/1/d/11dc14afeeb64dad18b916638aa287d7.png
which converges to n.

The sequence a in a continued fraction is typically written as: [a0; a1, a2, a3, ... an].
We will write ours in the same fashion, but with the repeating part between semicolons.

Your goal is to return the continued fraction of the square root of n.
Input: An integer, n. n will never be a perfect square.
Output: The continued fraction of sqrt(n).

Test Cases:
2 -> [1; 2;]
3 -> [1; 1, 2;]
19 -> [4; 2, 1, 3, 1, 2, 8;]

Shortest code wins. Good luck!

The continued fraction of a number n is a fraction of the following form:

http://upload.wikimedia.org/wikipedia/en/math/1/1/d/11dc14afeeb64dad18b916638aa287d7.png
which converges to n.

The sequence a in a continued fraction is typically written as: [a0; a1, a2, a3, ... an].
We will write ours in the same fashion, but with the repeating part between semicolons.

Your goal is to return the continued fraction of the square root of n.
Input: An integer, n. n will never be a perfect square.
Output: The continued fraction of sqrt(n).

Test Cases:
2 -> [1; 2;]
3 -> [1; 1, 2;]
19 -> [4; 2, 1, 3, 1, 2, 8;]

Shortest code wins. Good luck!

The continued fraction of a number n is a fraction of the following form:


which converges to n.

The sequence a in a continued fraction is typically written as: [a0; a1, a2, a3, ... an].
We will write ours in the same fashion, but with the repeating part between semicolons.

Your goal is to return the continued fraction of the square root of n.
Input: An integer, n. n will never be a perfect square.
Output: The continued fraction of sqrt(n).

Test Cases:
2 -> [1; 2;]
3 -> [1; 1, 2;]
19 -> [4; 2, 1, 3, 1, 2, 8;]

Shortest code wins. Good luck!

Tweeted twitter.com/#!/StackCodeGolf/status/214984655340965892
added 36 characters in body
Source Link
beary605
  • 4.4k
  • 2
  • 27
  • 53

The continued fraction of a number n is a fraction of the following form:

http://upload.wikimedia.org/wikipedia/en/math/1/1/d/11dc14afeeb64dad18b916638aa287d7.png
which converges to n.

The sequence a in a continued fraction is typically written as: [a0; a1, a2, a3, ... an].
We will write ours in the same fashion, but with the repeating part between semicolons.

Your goal is to return the continued fraction of the square root of n.
Input: An integer, n. n will never be a perfect square.
Output: The continued fraction of sqrt(n).

Test Cases:
2 -> [1; 2;]
3 -> [1; 1, 2;]
19 -> [4; 2, 1, 3, 1, 2, 8;]

Shortest code wins. Good luck!

The continued fraction of a number n is a fraction of the following form:

http://upload.wikimedia.org/wikipedia/en/math/1/1/d/11dc14afeeb64dad18b916638aa287d7.png
which converges to n.

The sequence a in a continued fraction is typically written as: [a0; a1, a2, a3, ... an].
We will write ours in the same fashion, but with the repeating part between semicolons.

Your goal is to return the continued fraction of the square root of n.
Input: An integer, n.
Output: The continued fraction of sqrt(n).

Test Cases:
2 -> [1; 2;]
3 -> [1; 1, 2;]
19 -> [4; 2, 1, 3, 1, 2, 8;]

Shortest code wins. Good luck!

The continued fraction of a number n is a fraction of the following form:

http://upload.wikimedia.org/wikipedia/en/math/1/1/d/11dc14afeeb64dad18b916638aa287d7.png
which converges to n.

The sequence a in a continued fraction is typically written as: [a0; a1, a2, a3, ... an].
We will write ours in the same fashion, but with the repeating part between semicolons.

Your goal is to return the continued fraction of the square root of n.
Input: An integer, n. n will never be a perfect square.
Output: The continued fraction of sqrt(n).

Test Cases:
2 -> [1; 2;]
3 -> [1; 1, 2;]
19 -> [4; 2, 1, 3, 1, 2, 8;]

Shortest code wins. Good luck!

added math-tag
Link
user unknown
  • 4.6k
  • 32
  • 32
Loading
Source Link
beary605
  • 4.4k
  • 2
  • 27
  • 53
Loading