Question: Is it more efficient to use select?

Tonight I came across something that OEIS had referenced as the maximum fermi dirac divisor of a number, so i decided it might be a good idea to study this concept by first figuring out how to enumerate the subset of these divisors.

But rather than specifically about this subject, i wanted to ask if my way of "enumeration of numbers meeting specific criteria" is inferior to other methods i have seen. For example this guy named Alois Heinz uses select in the following manner to obtain  the least divisor of a number that is greater than it's square root:

 

with(numtheory):

a:= n-> min(select(d-> is(d=n or d>sqrt(n)), divisors(n))):

Where as I have always been constructing piecewise expressions as seen in the example of what i have been doing tonight:


 

with(numtheory):

`&Fscr;` := proc (n) options operator, arrow; {seq(seq(piecewise(frac(ln(ln(divisors(n)[k])/ln(ithprime(j)))/ln(2)) = 0 and divisors(n)[k] <> 1 and divisors(n)[k] <> 2, divisors(n)[k], NULL), j = 1 .. pi(divisors(n)[k])), k = 1 .. nops(divisors(n)))} end proc

`&Fscr;`(200000)

{4, 5, 16, 25, 625}

(1)

``


 

Download 21052018.mw

 

So basically, because it is very hard for me to break habits once i have formed them, my question is, is it going to be beneficial for me to switch to this persons method of enumeration, or am i ok just to continue my way?

 

 

Please Wait...