Skip to main content

cs_lec_4

Prime Factorization

Each positive integer n has a set of prime factors: primes whose product is n

... 8=2∗2∗28=2*2*2 9=3∗39 = 3*3 10=2∗510=2*5 11=1111 = 11 12=2∗2∗312 = 2*2*3 ... One approach: Find the smallest prime factor of n, then divide by it 858=2∗429=2∗3∗143=2∗3∗11∗13858 = 2*429 = 2*3*143=2*3*11*13

WRite programs -> effective way say whatever function is wanted, and then write the function

Generalizing Patterns with Arguments Regular geometric shapes relate lengths and area. Shape: r2,π×r2,3×(3)/2r2r^2, \pi\times r^2 , 3\times \sqrt(3)/2r^2 FInding common structure allows for shared implementation -> No need to repeat oneself So using term(k), or term(whatever), then writing k