mersenneforum.org  

Go Back   mersenneforum.org > Great Internet Mersenne Prime Search > Software

Reply
 
Thread Tools
Old 2011-08-26, 12:09   #1
James Heinrich
 
James Heinrich's Avatar
 
"James Heinrich"
May 2004
ex-Northern Ontario

3,271 Posts
Default Command-line program for factoring small numbers

I'm looking for a simple *nix program to factor P-1 factors (which, most of the time, will confirm that they're prime). So relatively small numbers, typically under 150 bits. I want something like:
Quote:
>factor 17613769033772007210894662109212994801791
* 74835908771936093401
* 235365205324763482391
or
Quote:
>factor 455144877715893163583
* 455144877715893163583
What's my simplest option?
James Heinrich is offline   Reply With Quote
Old 2011-08-26, 13:03   #2
paulunderwood
 
paulunderwood's Avatar
 
Sep 2002
Database er0rr

2·3·599 Posts
Default

echo "factor(17613769033772007210894662109212994801791)" | gp -q

[74835908771936093401 1]

[235365205324763482391 1]



You could set up an alias with a parameter. Also you could tweak the output. Do any gurus want to give a solution?

Last fiddled with by paulunderwood on 2011-08-26 at 13:08
paulunderwood is offline   Reply With Quote
Old 2011-08-26, 13:10   #3
xilman
Bamboozled!
 
xilman's Avatar
 
"π’‰Ίπ’ŒŒπ’‡·π’†·π’€­"
May 2003
Down not across

32×11×107 Posts
Default

Quote:
Originally Posted by James Heinrich View Post
I'm looking for a simple *nix program to factor P-1 factors (which, most of the time, will confirm that they're prime). So relatively small numbers, typically under 150 bits. I want something like:orWhat's my simplest option?
[pcl@anubis PROCESS]$ echo "17613769033772007210894662109212994801791" | ecm -c 100 1000000
GMP-ECM 6.2.2 [powered by GMP 4.3.1] [ECM]
Input number is 17613769033772007210894662109212994801791 (41 digits)
Using B1=1000000, B2=1045563762, polynomial Dickson(6), sigma=816405928
Step 1 took 1183ms
Step 2 took 990ms
********** Factor found in step 2: 74835908771936093401
Found probable prime factor of 20 digits: 74835908771936093401
Probable prime cofactor 235365205324763482391 has 21 digits
[pcl@anubis PROCESS]$


Paul
xilman is offline   Reply With Quote
Old 2011-08-26, 13:12   #4
James Heinrich
 
James Heinrich's Avatar
 
"James Heinrich"
May 2004
ex-Northern Ontario

CC716 Posts
Default

Please go on the assumption that my *nix knowledge is nonexistant, you won't be far off...
Code:
$ echo "factor(17613769033772007210894662109212994801791)" | gp -q
-bash: gp: command not found
-bash: echo: write error: Broken pipe
Code:
$ echo "17613769033772007210894662109212994801791" | ecm -c 100 1000000
-bash: ecm: command not found
-bash: echo: write error: Broken pipe
Output formatting is irrelevant, I can take the output in whatever form it cares to present itself and reformat according to my needs, that's not an issue.

Last fiddled with by James Heinrich on 2011-08-26 at 13:13
James Heinrich is offline   Reply With Quote
Old 2011-08-26, 13:22   #5
paulunderwood
 
paulunderwood's Avatar
 
Sep 2002
Database er0rr

2·3·599 Posts
Default

-bash: gp: command not found

install pari-gp



I edited ~/.bashrc and added this as the last line

Code:
factro () { echo "factor($*)" | gp -q; }
saved it. Restarted the terminal and ran:

Code:
factro 7100001

[3 3]

[59 1]

[4457 1]

Last fiddled with by paulunderwood on 2011-08-26 at 13:43
paulunderwood is offline   Reply With Quote
Old 2011-08-26, 14:31   #6
James Heinrich
 
James Heinrich's Avatar
 
"James Heinrich"
May 2004
ex-Northern Ontario

3,271 Posts
Default

Quote:
Originally Posted by paulunderwood View Post
install pari-gp
Unfortunately my *nix-competance extends as far as beginner-level expertise with the commands "cd" and "ls", and not much beyond that.
(and it's a production webserver that I don't want to play with too much at risk of breaking things)

However, I have recently (yes, since posting...) that my server does in fact support PHP-gmp, and my PHP skills are considerably better, so I'll stick to hacking it out that way
James Heinrich is offline   Reply With Quote
Old 2011-08-26, 16:05   #7
jasonp
Tribal Bullet
 
jasonp's Avatar
 
Oct 2004

2·3·19·31 Posts
Default

Check the sticky in the factoring subforum here for links to many programs that can do what you want. On unix, though, you'll probably have to compile them.
jasonp is offline   Reply With Quote
Old 2011-08-26, 16:53   #8
xilman
Bamboozled!
 
xilman's Avatar
 
"π’‰Ίπ’ŒŒπ’‡·π’†·π’€­"
May 2003
Down not across

32×11×107 Posts
Default

Quote:
Originally Posted by jasonp View Post
Check the sticky in the factoring subforum here for links to many programs that can do what you want. On unix, though, you'll probably have to compile them.
Or ask the likes of me to compile them for you.

Paul
xilman is offline   Reply With Quote
Old 2011-08-26, 17:16   #9
James Heinrich
 
James Heinrich's Avatar
 
"James Heinrich"
May 2004
ex-Northern Ontario

3,271 Posts
Default

Quote:
Originally Posted by xilman View Post
Or ask the likes of me to compile them for you.
I may have to do that. I picked yafu at random and tried, and failed, ending up with:
Code:
[ yafu-1.28.4]$ make x86
gcc -g -O3 -fomit-frame-pointer -Wall  -I. -Iinclude -m32 -c -o arith/tfm/fp_mul_comba.o arith/tfm/fp_mul_comba.c
In file included from include/tfm.h:18,
                 from arith/tfm/fp_mul_comba.c:18:
include/yafu.h:49:17: error: gmp.h: No such file or directory
In file included from include/tfm.h:19,
                 from arith/tfm/fp_mul_comba.c:18:
include/arith.h:170: error: expected ')' before 'src'
include/arith.h:171: error: expected ')' before 'dest'
make: *** [arith/tfm/fp_mul_comba.o] Error 1
Of course, they supply precompiled binaries for Win32/64 and Linux64, but not Linux32, which is what I need :(
James Heinrich is offline   Reply With Quote
Old 2011-08-27, 16:32   #10
chris2be8
 
chris2be8's Avatar
 
Sep 2009

5×401 Posts
Default

Quote:
Originally Posted by James Heinrich View Post
Unfortunately my *nix-competance extends as far as beginner-level expertise with the commands "cd" and "ls", and not much beyond that.
For beginners the best advice is to read the man pages. So typing "man ls" will give you all the options ls supports (probably more than you want).

"man" has it's own man page (type "man man" to read it) and "man intro" gives a relatively gentle introduction to Linux.

I often have 1 window to enter commands and another to read the man page for the command I'm using. Even experts don't want to to guess when using commands like fsck.

Chris K.
chris2be8 is offline   Reply With Quote
Old 2011-08-27, 18:31   #11
James Heinrich
 
James Heinrich's Avatar
 
"James Heinrich"
May 2004
ex-Northern Ontario

3,271 Posts
Default

man pages are fine to know what a certain command does, but are not all that useful in solving compile-time errors.
James Heinrich is offline   Reply With Quote
Reply

Thread Tools


Similar Threads
Thread Thread Starter Forum Replies Last Post
Mail from command line pepi37 Linux 4 2015-07-16 22:06
Windows command line mu5tan6 Software 14 2015-03-20 17:21
command line switch wongnog Information & Answers 1 2008-07-20 11:29
NewPGen from the command line monst Software 19 2008-01-31 07:07
A small factoring program Yamato Factoring 2 2007-11-21 23:29

All times are UTC. The time now is 08:38.

Sun Mar 7 08:38:24 UTC 2021 up 94 days, 4:49, 0 users, load averages: 3.28, 3.13, 3.06

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2021, Jelsoft Enterprises Ltd.

This forum has received and complied with 0 (zero) government requests for information.

Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation.
A copy of the license is included in the FAQ.