![]() |
![]() |
#1 |
"Mike"
Aug 2002
22·5·397 Posts |
![]()
http://mathworld.wolfram.com/HomePrime.html
Obviously, there are better ways to code this, but I had a lot of fun and learned some stuff in the process... Too bad "factor" bails so easily... Code:
#!/bin/sh counter=1 while [ $counter != 48 ] do a=$counter while : do temp=`factor $a` b=`echo $temp | cut -d ":" -f2 | tr -d " "` echo `echo $temp | tr ":" "=" | sed 's/=/ =/'` if [ $a = $b ] then break fi a=$b done echo (( counter += 1 )) done ![]() |
![]() |
![]() |
![]() |
#2 |
"Sander"
Oct 2002
52.345322,5.52471
29×41 Posts |
![]()
No script, and definitely not simple, but i have an UBasic program to calculate these numbers with the use of trail factoring and ECM.
It's much faster though. |
![]() |
![]() |
![]() |
#3 |
Jun 2004
UK
139 Posts |
![]() Code:
def homePrime(x): y = int("".join(factor(x))) while y != x: x, y = y, int("".join(factor(y))) return y |
![]() |
![]() |
![]() |
#4 |
"Patrik Johansson"
Aug 2002
Uppsala, Sweden
1101010012 Posts |
![]()
1. Regarding marc's code: What language is this? How should one start it?
2. Regarding the `` in xyzzy's script: I run a script with a substitution, and once every 50000 times or so I seem to get the error message "Can't reopen pipe to command substitution: No child processes." Does anyone know anything about this? (50000 is just a guess, but it is something between 10^4 and 10^5.) |
![]() |
![]() |
![]() |
#5 |
Jun 2004
UK
139 Posts |
![]()
That's Python. You just need a Python installation and a Python factor() function.
|
![]() |
![]() |
![]() |
#6 | |
Jan 2005
Caught in a sieve
18B16 Posts |
![]()
Here's a PERL program that uses the same method the original script - calling other factoring programs. But it uses either the simple factor program or the MIRACL factor program from ftp://ftp.compapp.dcu.ie/pub/crypto/miracl.zip So it works much better, and can find all Homeprimes < 100 that are known.
Code:
# Find Homeprimes of the given arguments. # http://mathworld.wolfram.com/HomePrime.html # The MIRACL factor program is freeware from Shamus Software, Dublin, Ireland # Full C source code and MIRACL multiprecision library available # Email to mscott@indigo.ie for details # Web page http://indigo.ie/~mscott # Source code from ftp://ftp.compapp.dcu.ie/pub/crypto/miracl.zip use strict; use FileHandle; # Compare two numbers too big to fit as ints or longs. sub numStringCmp ($$) { (my $s1, my $s2) = @_; my $rel; # First compare the sizes. $rel = (length($s1) <=> length($s2)); return $rel if($rel != 0); # Then compare the equal-size strings. return $s1 cmp $s2; } sub factorList ($) { (my $cand) = @_; #print "trying $cand\n"; # Localize the filehandle $IN. my $IN = FileHandle->new(); if(length($cand) < 12 && $cand =~ /^[0-9]*$/) { # Use the simpler factorer. open($IN, "factor $cand |") || die "Couldn't factor: $!"; my $factline = <$IN>; close $IN; chomp $factline; (undef, my @factors) = split(/ /, $factline); return @factors; } # Make sure factor2 can handle a number this size and type. my $args = ""; $args .= '-d '.(length($cand)+2).' ' if(length($cand) >= 149); $args .= '-f ' if($cand =~ /[+\-*#]/); # Handle formulas. open($IN, "factor2 -s $args$cand |") || die "Couldn't factor: $!"; if($cand =~ /[+\-*#]/) { # Handle formulas. # The first line is the candidate computed from the # formula, if one was given. $cand = <$IN>; chomp($cand); } my @factors = (); while(<$IN>) { last if(/^this number is prime!/); s/[^0-9 &]//g; if(/^& /) { (undef, my $num) = split(/ /); # This could mean the factorer couldn't factor this # factor, or that it couldn't be bothered to. # The following line avoids recursive loops. die "Couldn't factor $cand\n" if($num eq $cand); @factors = (@factors, factorList($num)); next; } push @factors, $_; } close $IN; return sort numStringCmp @factors; } foreach my $cand (@ARGV) { my $x = $cand; my $y = join('', factorList($cand)); while($y ne $x) { $x = $y; print "Factoring $x\n"; $y = join('', factorList($x)); } print $cand, ': ', $y, "\n"; } - PERL - The MIRACL factor.exe program, renamed to factor2 - The GNU factor program (optional). If you don't have/want it, change "length($cand) < 12" to "length($cand) < 0". Oh, and I thought you might like to see how far it gets with that unknown one, 49=77: Quote:
|
|
![]() |
![]() |
![]() |
#7 | |
6809 > 6502
"""""""""""""""""""
Aug 2003
101×103 Posts
22×33×5×17 Posts |
![]() Quote:
717133578549596081307550033105521651212411487965543982552577200370139716504126134573487841 then 1013140899118131107973159425637372267366503456262916700717404858255585899140058606434748914537 (composite) Last fiddled with by Uncwilly on 2005-01-06 at 14:23 |
|
![]() |
![]() |
![]() |
#8 | |
6809 > 6502
"""""""""""""""""""
Aug 2003
101×103 Posts
22·33·5·17 Posts |
![]() Quote:
346369145517616832561580518436338147877062893457679622195929206654524672587613049343558394373396338194585783775269785675210636696425094776859733305947996048061499249566197147212934512427988113420226762897 There have been around 5500 ECM curves run on it. |
|
![]() |
![]() |
![]() |
#9 | |
"Sander"
Oct 2002
52.345322,5.52471
29·41 Posts |
![]() Quote:
5500 curves with B1=11M 9650 curves with B1=43M 2280 curves with B1=110M |
|
![]() |
![]() |
![]() |
Thread Tools | |
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Home Primes, Reloaded | kar_bon | Factoring | 419 | 2020-10-25 10:06 |
15e batch of WU's NFS@Home | pinhodecarlos | NFS@Home | 31 | 2020-01-21 21:49 |
NFS@Home 2,1207-, maybe? | pinhodecarlos | NFS@Home | 25 | 2015-07-25 22:46 |
Reverse home primes | themaster | Factoring | 12 | 2008-09-27 14:44 |
Home schooling | eepiccolo | Soap Box | 20 | 2004-02-26 12:53 |