Cody

# Problem 1289. Evaluating continued fractions

Solution 984758

Submitted on 27 Sep 2016 by Ben Petschel
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
c=ones(1,40); x=(1+sqrt(5))/2; y=contfrac(c); assert(abs(y-x)<1e-15)

2   Pass
c=[3 7 15 1 292 1 1 1 2 1 3 1 14]; x=pi; y=contfrac(c); assert(abs(y-x)<1e-15)

3   Pass
c=[3 7 15 1]; x=355/113; y=contfrac(c); assert(abs(y-x)<1e-15)

4   Pass
c=[1 1 1 3 1 5 1 7 1 9 1 11 1 13 1 15 1 17 1 19 1; 2 1 2 1 1 4 1 1 6 1 1 8 1 1 10 1 1 12 1 1 14]; x=[tan(1);exp(1)]; y=contfrac(c); assert(max(abs(y-x))<1e-15)

5   Pass
c=(1:9)'*[1 2*ones(1,20)]; x=sqrt([2;5;10;17;26;37;50;65;82]); y=contfrac(c); assert(max(abs(y-x))<1e-15)
{"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://jp.mathworks.com/matlabcentral/cody/problems/1289-evaluating-continued-fractions/solutions/984758", "fetch_time": 1580138866000000000, "content_mime_type": "text/html", "warc_filename": "crawl-data/CC-MAIN-2020-05/segments/1579251700988.64/warc/CC-MAIN-20200127143516-20200127173516-00162.warc.gz", "warc_record_offset": 500218892, "warc_record_length": 15633, "token_count": 374, "char_count": 796, "score": 3.6875, "int_score": 4, "crawl": "CC-MAIN-2020-05", "snapshot_type": "latest", "language": "en", "language_score": 0.39756086468696594, "file_path": "/sailhome/yjruan/project/latent-lm/data/processed/finemath-4plus/finemath-4plus/train-00012-of-00064.parquet"}