Cody

# Problem 897. Finite Continued Fraction

Solution 126371

Submitted on 10 Aug 2012 by Khaled Hamed
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

### Test Suite

Test Status Code Input and Output
1   Pass
%% x = pi; n = 50; y_correct = [3 7 15 1 292 1 1 1 2 1 3 1 14 3 3 23 ... 1 1 7 4 35 1 1 1 2 3 3 3 3 1 1 14 6 4 5 1 7 1 5 1 1 3 18 2 1 2 4 2 96 2]; assert(isequal(finite_continued_fraction(x,n),y_correct))

s = 3 x = 7.0625 s = 7 x = 15.9966 s = 15 x = 1.0034 s = 1 x = 292.6346 s = 292 x = 1.5758 s = 1 x = 1.7367 s = 1 x = 1.3575 s = 1 x = 2.7974 s = 2 x = 1.2542 s = 1 x = 3.9346 s = 3 x = 1.0699 s = 1 x = 14.3004 s = 14 x = 3.3287 s = 3 x = 3.0425 s = 3 x = 23.5323 s = 23 x = 1.8788 s = 1 x = 1.1380 s = 1 x = 7.2483 s = 7 x = 4.0281 s = 4 x = 35.6292 s = 35 x = 1.5892 s = 1 x = 1.6972 s = 1 x = 1.4343 s = 1 x = 2.3028 s = 2 x = 3.3026 s = 3 x = 3.3045 s = 3 x = 3.2843 s = 3 x = 3.5171 s = 3 x = 1.9340 s = 1 x = 1.0706 s = 1 x = 14.1603 s = 14 x = 6.2398 s = 6 x = 4.1699 s = 4 x = 5.8870 s = 5 x = 1.1274 s = 1 x = 7.8478 s = 7 x = 1.1795 s = 1 x = 5.5703 s = 5 x = 1.7534 s = 1 x = 1.3274 s = 1 x = 3.0544 s = 3 x = 18.3718 s = 18 x = 2.6897 s = 2 x = 1.4500 s = 1 x = 2.2223 s = 2 x = 4.4974 s = 4 x = 2.0104 s = 2 x = 96.4358 s = 96 x = 2.2946 s = 2 x = 3.3946

2   Pass
%% x = 1; n = 10; y_correct = 1; assert(isequal(finite_continued_fraction(x,n),y_correct))

s = 1

3   Pass
%% x = 5.2; n = 5; y_correct = [5 4 1]; assert(isequal(finite_continued_fraction(x,n),y_correct))

s = 5 x = 5.0000 s = 4 x = 1.0000 s = 1

4   Pass
%% x = 15625/6842; n = 7; y_correct = [2 3 1 1 9 1 1]; assert(isequal(finite_continued_fraction(x,n),y_correct))

s = 2 x = 3.5250 s = 3 x = 1.9048 s = 1 x = 1.1052 s = 1 x = 9.5052 s = 9 x = 1.9796 s = 1 x = 1.0208 s = 1 x = 48.0000
{"found_math": false, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 0, "mathjax_display_tex": 0, "mathjax_asciimath": 0, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0, "katex": 0, "math-container": 0, "wp-katex-eq": 0, "align": 0, "equation": 0, "x-ck12": 0, "texerror": 0, "url": "https://de.mathworks.com/matlabcentral/cody/problems/897-finite-continued-fraction/solutions/126371", "fetch_time": 1579448761000000000, "content_mime_type": "text/html", "warc_filename": "crawl-data/CC-MAIN-2020-05/segments/1579250594662.6/warc/CC-MAIN-20200119151736-20200119175736-00134.warc.gz", "warc_record_offset": 408804817, "warc_record_length": 15756, "token_count": 990, "char_count": 1848, "score": 3.625, "int_score": 4, "crawl": "CC-MAIN-2020-05", "snapshot_type": "latest", "language": "en", "language_score": 0.4509495198726654, "file_path": "/sailhome/yjruan/project/latent-lm/data/processed/finemath-4plus/finemath-4plus/train-00024-of-00064.parquet"}