# OK to post # HW2, RDB, 2024-01-28 # 3. MyIfactor := proc(n) local p, res: if n = 1 then return []: fi: p := 2: while n mod p > 0 do p := nextprime(p) end: res := MyIfactor(n / p): [p, op(res)]: end: big_time := 0: small_time := 0: for k from 1 to 10 do big := rand(10^7..10^8)(): big: ifactor(big): big_time += time(MyIfactor(big)): small_time += time(ifactor(big)): od: big_time / 10; small_time / 10; # As expected, MyIfactor is terrible compared to ifactor.