tech-userlevel archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: silly behavior of factor(6)



On Thu, Apr 22, 2010 at 09:43:56PM +0300, markucz%gmail.com@localhost wrote:
> > Since the manual specifies "positive integer", 0 is invalid input (it's 
> > not in Z+).  If one instead means "non-negative" (x>=0), 0 has infinite 
> > factors.  The manual might want to specify (x>0) to note that positive 
> > does not mean non-negative.
> I still remember my math, thank you very much. Strictly speaking, a '1' isn't
> valid argument either, since it has no prime factors. So if you break the
> rules once, why not twice? factor should either stay as it is, or display
> '0: 0' for the sake of consistency. FYI, GNU factor accepts both 0 and 1 but
> outputs '0:' and '1:'.
> 
> Just my two pennies worth.

But, in math many times base cases are defined. For example, when dealing with 
Fibonacci numbers Fib(0) = 0 and Fib(1) = 1 even though nothing there is 
nothing prior in the sequence to generate those two.

So why couldn't we define factor(0) = 0 and factor(1) = 1 even if in the 
strictest sense they may not be factorable?

Also, why are we limiting to Z+? The manpage states it can factor -2147483648 
to 2147483647, but when I try to factor -10, it gives one of two errors 
(because apparently a negative number can't be the first number factored):

        $ factor -10
        factor: unknown option -- 1
        usage: factor [value ...] 

        $ factor 10: -10 
        10: 2 5
        factor: negative numbers aren't permitted.

-- 
Christopher Berardi
http://www.natoufa.com/

Be still, and know that I am God (Psalms 46:10)


Home | Main Index | Thread Index | Old Index