Beta
Square Root of 2
Description:
The method of periodic continued fractions is one of the many ways to calculate the square root of a natural number. This method uses as denominator a repetition for fractions. This repetition can be done by a fixed number of times.
For example, by repeating 2 times the continued fraction to calculate the square root of 2, we have the following equation.
Input
The input is a natural number n (0 ≤ n ≤ 1000) that indicates the quantity of denominator repetitions in the continued fraction.
Output
The output is the approximate value of the square root with 10 decimal places.
Examples
calculate(0) => 1.0000000000
calculate(1) => 1.5000000000
calculate(5) => 1.4142857143
Notes
Fundamentals
Algorithms
Mathematics
Similar Kata:
Stats:
Created | Jan 31, 2017 |
Published | Jan 31, 2017 |
Warriors Trained | 170 |
Total Skips | 36 |
Total Code Submissions | 93 |
Total Times Completed | 31 |
Java Completions | 31 |
Total Stars | 3 |
% of votes with a positive feedback rating | 82% of 22 |
Total "Very Satisfied" Votes | 14 |
Total "Somewhat Satisfied" Votes | 8 |
Total "Not Satisfied" Votes | 0 |
Total Rank Assessments | 19 |
Average Assessed Rank | 7 kyu |
Highest Assessed Rank | 6 kyu |
Lowest Assessed Rank | 8 kyu |