LinuxQuestions.org
View the Most Wanted LQ Wiki articles.
Go Back   LinuxQuestions.org > Forums > Linux > Linux - General
User Name
Password
Linux - General This 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

Tags used in this thread
Popular LQ Tags ,

Reply
 
Thread Tools
Old 09-01-2006, 07:21 AM   #1
dggoldst
LQ Newbie
 
Registered: Mar 2006
Posts: 12
Thanked: 0
Why do you think the "factor" command exists?


[Log in to get rid of this advertisement]
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
dggoldst is offline  
Tag This Post ,
Reply With Quote
Old 09-01-2006, 07:48 AM   #2
jlliagre
Moderator
 
Registered: Feb 2004
Location: Outside Paris, under a rock ...
Distribution: Solaris & OpenSolaris based distros, Ubuntu
Posts: 8,132
Thanked: 86
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
jlliagre is offline     Reply With Quote
Old 09-01-2006, 08:23 AM   #3
dggoldst
LQ Newbie
 
Registered: Mar 2006
Posts: 12
Thanked: 0

Original Poster
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?
dggoldst is offline     Reply With Quote
Old 09-01-2006, 08:38 AM   #4
jlliagre
Moderator
 
Registered: Feb 2004
Location: Outside Paris, under a rock ...
Distribution: Solaris & OpenSolaris based distros, Ubuntu
Posts: 8,132
Thanked: 86
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 01:27 PM..
jlliagre is offline     Reply With Quote
Old 09-15-2006, 12:31 PM   #5
dggoldst
LQ Newbie
 
Registered: Mar 2006
Posts: 12
Thanked: 0

Original Poster
Any other thoughts on this?
dggoldst is offline     Reply With Quote
Old 09-15-2006, 04:31 PM   #6
J.W.
Moderator
 
Registered: Mar 2003
Location: Milwaukee, WI
Distribution: Slack v12, SuSE v11.1, Mint v7
Posts: 6,620
Thanked: 5
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
J.W. is offline     Reply With Quote

Reply

Bookmarks


Thread Tools

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 Off
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 08: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 07:02 PM
Tiny Sofa 2.0 - I thought "halt", "reboot" were only root command ?? sorcerer Linux - Distributions 1 08-21-2004 04:28 PM
"segmentation error" when issuing "useradd" command through terminal with RH 9.0 kaihuang Linux - General 0 10-22-2003 12:47 AM
"A duplicate name exists on the network" error with samba colpaarm Linux - Software 0 07-21-2003 03:55 PM


All times are GMT -5. The time now is 02:12 AM.

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
RSS2  LQ Podcast
RSS2  LQ Radio
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: @linuxquestions
Open Source Consulting | Domain Registration