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 |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
 |
GNU/Linux Basic Guide
This 255-page guide will provide you with the keys to understand the philosophy of free software, teach you how to use and handle it, and give you the tools required to move easily in the world of GNU/Linux. Many users and administrators will be taking their first steps with this GNU/Linux Basic guide and it will show you how to approach and solve the problems you encounter.
Click Here to receive this Complete Guide absolutely free. |
|
 |
09-01-2006, 06:21 AM
|
#1
|
|
LQ Newbie
Registered: Mar 2006
Posts: 12
Rep:
|
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
|
|
|
|
09-01-2006, 06:48 AM
|
#2
|
|
Moderator
Registered: Feb 2004
Location: Outside Paris
Distribution: Solaris10, Solaris 11, Ubuntu, OL
Posts: 9,311
|
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
|
|
|
|
09-01-2006, 07:23 AM
|
#3
|
|
LQ Newbie
Registered: Mar 2006
Posts: 12
Original Poster
Rep:
|
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? 
|
|
|
|
09-01-2006, 07:38 AM
|
#4
|
|
Moderator
Registered: Feb 2004
Location: Outside Paris
Distribution: Solaris10, Solaris 11, Ubuntu, OL
Posts: 9,311
|
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.
|
|
|
|
09-15-2006, 11:31 AM
|
#5
|
|
LQ Newbie
Registered: Mar 2006
Posts: 12
Original Poster
Rep:
|
Any other thoughts on this?
|
|
|
|
09-15-2006, 03:31 PM
|
#6
|
|
LQ Veteran
Registered: Mar 2003
Location: Milwaukee, WI
Distribution: Mint
Posts: 6,642
Rep:
|
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
|
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -5. The time now is 03:04 AM.
|
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|