LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices

Reply
 
Search this Thread
Old 09-01-2006, 06:21 AM   #1
dggoldst
LQ Newbie
 
Registered: Mar 2006
Posts: 12

Rep: Reputation: 0
Why do you think the "factor" command exists?


I've noticed there's a command line call "factor", which prints the prime factors of a number.

Does anybody have an idea why this is included as a standard Unix/Linux routine? Is it really that important to do prime factorizations on the command line? Most programming languages don't have a factor command, so why does a very popular OS have one?

There must be some interesting history to this I'm missing. The only use I've gotten out of factor is getting a rough comparion of processor speeds on my various boxes by doing
factor 18446744073709551557

...which takes from 52 seconds to over 2 minutes, depending on the machine

Yours in curiosity,
Dan
 
Old 09-01-2006, 06:48 AM   #2
jlliagre
Moderator
 
Registered: Feb 2004
Location: Outside Paris
Distribution: Solaris10, Solaris 11, Mint, OL
Posts: 9,482

Rep: Reputation: 354Reputation: 354Reputation: 354Reputation: 354
Well, I think it exists because it has always been there.

The venerable Unix Version 7 manual (Jan 1979) has it and states:

Maximum time to factor is proportional to √n and occurs when n is prime or the square of a prime. It takes 1 minute to factor a prime near 10 14 on a PDP11.

It improves since that time (x240), but not as much as I was expecting:
Code:
time factor 99999999999971
99999999999971
     99999999999971


real    0m0.25s
user    0m0.17s
sys     0m0.00s
 
Old 09-01-2006, 07:23 AM   #3
dggoldst
LQ Newbie
 
Registered: Mar 2006
Posts: 12

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by jlliagre
Well, I think it exists because it has always been there.
Oui, exactement. But why did someone put it there in the first place?
 
Old 09-01-2006, 07:38 AM   #4
jlliagre
Moderator
 
Registered: Feb 2004
Location: Outside Paris
Distribution: Solaris10, Solaris 11, Mint, OL
Posts: 9,482

Rep: Reputation: 354Reputation: 354Reputation: 354Reputation: 354
The benchmark theory may be correct, I have never seen this command actually used in a script.

Note that OpenSolaris is providing a source code which is certainly very close to the original one. There are no comments about the intended use of it though.

http://cvs.opensolaris.org/source/xr...actor/factor.c

Gnu/Linux is having a different implementation without the original 10^14 limit, so these guys took their job seriously ...

Last edited by jlliagre; 09-15-2006 at 12:27 PM.
 
Old 09-15-2006, 11:31 AM   #5
dggoldst
LQ Newbie
 
Registered: Mar 2006
Posts: 12

Original Poster
Rep: Reputation: 0
Any other thoughts on this?
 
Old 09-15-2006, 03:31 PM   #6
J.W.
LQ Veteran
 
Registered: Mar 2003
Location: Milwaukee, WI
Distribution: Mint
Posts: 6,642

Rep: Reputation: 69
I would guess that it's there because at the time Unix was originally developed around 1970, the only real market for computers was large, well-funded organizations, and at that time, number crunching was one of a computer's primary uses. Factoring is a useful function for certain areas of study (eg, in scientific labs, universities, etc) and by including a simple-to-use utility to compute factors in Unix, it may have been a minor but useful selling point. Sort of like cup holders in a car - they aren't really necessary, but to a potential customer, having them is better than not having them. Same with a factor command. Just speculation, of course
 
  


Reply

Tags
history


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Shell Script: Find "Word" Run "Command" granatica Linux - Software 5 07-25-2007 07:42 AM
"DeVirgined" by FC5, new to MS's parallel Universe of which I heard freedom exists! five00seven LinuxQuestions.org Member Intro 1 06-05-2006 06:02 PM
Tiny Sofa 2.0 - I thought "halt", "reboot" were only root command ?? sorcerer Linux - Distributions 1 08-21-2004 03:28 PM
"segmentation error" when issuing "useradd" command through terminal with RH 9.0 kaihuang Linux - General 0 10-21-2003 11:47 PM
"A duplicate name exists on the network" error with samba colpaarm Linux - Software 0 07-21-2003 02:55 PM


All times are GMT -5. The time now is 12:55 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration