# SICP Solutions

### Section - Procedures and the Processes They Generate

#### Exercise 1.24

Present implementation of random is not under sicp language. So I shall be importing it additionally. Also, random works only on numbers less than 4294967087, so I created my-random using random. It is however more costlier than random as it internally calls random twice for numbers beyond integer range.

Now I shall redraw the table from previous exercise including values from this exercise:

Numbers Orignal approach with no skipping Skipping even numbers by calling next-divisor Skipping even numbers directly fermat-prime?
1009 4 3 2 521
1013 4 3 2 541
1019 4 3 2 561
10007 12 9 7 661
10009 26 8 7 661
10037 13 7 5 671
100003 41 26 20 781
100019 40 27 19 801
100043 40 26 19 811
1000003 157 83 62 871
1000033 126 82 63 861
1000037 127 83 63 881
10000000000037 388727 279466 194440 6381
10000000000051 388108 279058 192753 6141
10000000000099 394797 304850 207065 6271
100000000000031 1238697 8375991 6426951 6971
100000000000067 1240527 8306311 6561041 7021

As we can see that exponential increments in input size causes only linear changes in processing-time using fermat-prime. Also we can note that for small numbers fermat-prime takes much more time because we are calling random function and trying multiple times(25). But as input size increases, fermat-test is much faster than the linear ones.
{"extraction_info": {"found_math": true, "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": 1, "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, "math_score": 0.4466356933116913, "perplexity": 1958.2067647940219}, "config": {"markdown_headings": true, "markdown_code": true, "boilerplate_config": {"ratio_threshold": 0.18, "absolute_threshold": 10, "end_threshold": 15, "enable": true}, "remove_buttons": true, "remove_image_figures": true, "remove_link_clusters": true, "table_config": {"min_rows": 2, "min_cols": 3, "format": "plain"}, "remove_chinese": true, "remove_edit_buttons": true, "extract_latex": true}, "warc_path": "s3://commoncrawl/crawl-data/CC-MAIN-2021-10/segments/1614178351134.11/warc/CC-MAIN-20210225124124-20210225154124-00425.warc.gz"}