# 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.