mersenneforum.org Aliquot sequences that start on the integer powers n^i
 Register FAQ Search Today's Posts Mark Forums Read

2021-02-14, 17:07   #782
EdH

"Ed Hall"
Dec 2009

47·79 Posts

Quote:
 Originally Posted by RichD @EdH: You can include base 43 in your script. All exponents (up to 77) are initialized but not ready to be inserted in the master table. Edit: Oops, late to party for posting...
No problem, Rich. I hadn't gone all the way to i=77, so I reran it to 77, and it turned out the same, anyway..

Unfortunately, I looked at my script and found it calls a C++ program that I wrote to do part of the work, so it's a little more complicated than I considered before. I'll have to see if I can translate the C++ portion into Bash, if I'm going to post a script here. This may be a while.

 2021-02-14, 18:12 #783 garambois     "Garambois Jean-Luc" Oct 2011 France 571 Posts OK, thanks for the mergers. I suspected that there would be a lot for base 37. I will check these mergers before the next update. It is difficult for me to find mergers, but it is much faster for me to verify them. Edwin, I hope I can use the script you are going to send us !
2021-02-14, 23:02   #784
EdH

"Ed Hall"
Dec 2009

72018 Posts

Quote:
 Originally Posted by garambois . . . Edwin, I hope I can use the script you are going to send us !
Well, I see now why I used a C++ program with my Bash script - I'm working on a purely Bash script and finding that what my original Bash/C++ setup did in a few seconds, it is taking the purely Bash script many minutes to perform. It is taking two minutes just to read the 80 digit text file into two arrays!

i might just provide the C++ program and the compile command line. But, I need to clean it up first.

More later. . .

2021-02-15, 01:23   #785
EdH

"Ed Hall"
Dec 2009

1110100000012 Posts

The pure Bash script appears to take about 6 times longer to run, but a second script can call the first multiple times and can be left to walk through tables overnight.

A sample run:
Code:
$bash alimerge3.sh 37 1 80 Reading OE_3000000_C80.txt . . . done! (104 seconds) Checking base 37 from 1 through 80 . . . 37^6:i126 merges with 109920:i1275 37^8:i151 merges with 1632:i37 37^12:i1057 merges with 10824:i28 37^18:i1430 merges with 3366:i2 37^22:i519 merges with 1567300:i0 37^30:i1193 merges with 35856:i3 Run time: 1211 seconds Here's the script: Code: #!/bin/bash ################################################################### ### This script is designed to find merges in the tables at the ### ### "Aliquot sequences starting on integer powers n^i" page: ### ### http://www.aliquotes.com/aliquotes_puissances_entieres.html ### ### To use this script, you first need a copy of the 80 digit ### ### file "OE_3000000_C80.txt" found at: ### ### http://www.aliquotes.com/OE_3000000_C80.txt ### ### If the file is not found in the working directory, a prompt ### ### allows it to be downloaded. Then, supply a command line ### ### with the base, first and last exponents to check. ### ### For example: ### ###$ bash <this script name> 37 1 80                       ###
### Alternately, you can just call the script and it will       ###
### prompt for the base, first and last values.                 ###
###################################################################

IFS='
'
declare -a seqs
declare -a C80s
scount=0

if [ ${#1} -lt 1 ] then printf "Base: " read base else base=${1}
fi

if [ ${#2} -lt 1 ] then printf "Starting exponent: " read start else start=${2}
fi

if [ ${#3} -lt 1 ] then printf "Last exponent: " read last else last=${3}
fi

if [ ! -e OE_3000000_C80.txt ]
then
echo "http://www.aliquotes.com/OE_3000000_C80.txt?"
printf "(y/[n]): "
if [ "$retyn" == "y" ] then wget "http://www.aliquotes.com/OE_3000000_C80.txt" -q -O OE_3000000_C80.txt fi fi if [ -e OE_3000000_C80.txt ] then printf "Reading OE_3000000_C80.txt . . . " exec <"OE_3000000_C80.txt" while read line do case$line in
" "*) temp=${line:1} space=$(echo expr index "$temp" \ ) seqs[scount]=${temp:0:${space}-1} C80s[scount]=${temp:${space}} let scount=${scount}+1
;;
esac
done
echo "done! ($SECONDS seconds)" fi if [$scount -gt 1000 ]
then
echo "Checking base ${base} from${start} through ${last} . . ." for (( i =${start}; i <= ${last}; i++ )) do tempC80="" aliseq1="" wget "http://www.factordb.com/elf.php?seq=${base}^${i}&type=1" -q -O aliseq0 exec <"aliseq0" while read line do period=$(echo expr index "$line" .) equals=$(echo expr index "$line" =) let diff=${equals}-${period} if [$diff -eq 85 ]
then
tempC80="${line:${period}+3:80}"
fi
done
if [ ${#tempC80} -eq 80 ] then for (( j = 0; j <$scount; j++ ))
do
if [ "${tempC80}" == "${C80s[$j]}" ] then aliseq1=${seqs[$j]} fi done fi if [${#aliseq1} -gt 2 ]
then
declare -a tempseq0
ali0i=0

exec <"aliseq0"
do
period=$(echo expr index "$line0" .)
tempseq0[$ali0i]=${line0:${period}} let ali0i=${ali0i}+1
done

wget "http://www.factordb.com/elf.php?seq=${aliseq1}&type=1" -q -O aliseq1 declare -a tempseq1 ali1i=0 exec <"aliseq1" while read line1 do period=$(echo expr index "$line1" .) tempseq1[$ali1i]=${line1:${period}}
let ali1i=${ali1i}+1 done for (( k = 0; k <$ali0i; k++ ))
do
for (( l = 0; l < $ali1i; l++ )) do if [ "${tempseq0[$k]}" == "${tempseq1[$l]}" ] then echo "$base^${i}:i${k} merges with ${aliseq1}:i${l}"
l=$ali1i k=$ali0i
fi
done
done
unset tempseq0
unset tempseq1
fi
done
fi

echo "Run time: \$SECONDS seconds"
The script is also attached below.
Attached Files
 alimerge3.sh.txt (4.3 KB, 12 views)

Last fiddled with by EdH on 2021-02-15 at 14:03

2021-02-15, 01:36   #786
Happy5214

"Alexander"
Nov 2008
The Alamo City

22×149 Posts

Quote:
 Originally Posted by EdH The pure Bash script appears to take about 6 times longer to run, but a second script can call the first multiple times and can be left to walk through tables overnight. [Code blocks omitted.]
A couple of notes. One, can you reformat the existence test for OE_3000000_C80.txt to retrieve it using wget if it's not already there? Second, you wouldn't need to say "bash" on the command line if the shebang were formatted properly. It's basically useless as it is.

2021-02-15, 02:18   #787
EdH

"Ed Hall"
Dec 2009

47×79 Posts

Quote:
 Originally Posted by Happy5214 A couple of notes. One, can you reformat the existence test for OE_3000000_C80.txt to retrieve it using wget if it's not already there? Second, you wouldn't need to say "bash" on the command line if the shebang were formatted properly. It's basically useless as it is.
Thanks! I fixed the shebang. I always use "bash " because if I don't, I have to manually change the permissions to reflect "Allow executing file as program" for any script I write.

I'll add the file retrieval if not found. I normally shy away from adding that into scripts, but in this case, the script is already going to the db for files. Maybe I'll add it as a choice. Let me play with it a bit before I change it here.

Thanks for all the help, Happy5214!

Last fiddled with by EdH on 2021-02-15 at 03:21 Reason: Reason provided above

 2021-02-15, 13:34 #788 EdH     "Ed Hall" Dec 2009 Adirondack Mtns 47×79 Posts Anyone who has looked at my script for Aliquot merges, please see the note in the original post. Any assistance would be appreciated.
2021-02-15, 13:49   #789
Happy5214

"Alexander"
Nov 2008
The Alamo City

11248 Posts

Quote:
 Originally Posted by EdH Anyone who has looked at my script for Aliquot merges, please see the note in the original post. Any assistance would be appreciated.
All of the lines in the code block have trailing spaces.

2021-02-15, 14:09   #790
EdH

"Ed Hall"
Dec 2009

E8116 Posts

Quote:
 Originally Posted by Happy5214 All of the lines in the code block have trailing spaces.
Thank You! For all but one line, it probably wouldn't matter, but:
Code:
IFS='
'
was truly corrupted.

Now, both the code block and the attachment work for me.

Much appreciated!

 2021-02-15, 17:40 #791 garambois     "Garambois Jean-Luc" Oct 2011 France 57110 Posts Many, many thanks Edwin ! I manage to get this program to work ! This tool will be very valuable to me ! I'll keep it running regularly and I keep you posted if I spot any malfunctions. Did I understand correctly, you also have a C++ program that does this job faster ? This other program would also interest me.
2021-02-15, 18:32   #792
EdH

"Ed Hall"
Dec 2009

E8116 Posts

Quote:
 Originally Posted by garambois Many, many thanks Edwin ! I manage to get this program to work ! This tool will be very valuable to me ! I'll keep it running regularly and I keep you posted if I spot any malfunctions. Did I understand correctly, you also have a C++ program that does this job faster ? This other program would also interest me.
Thanks for letting me know it works for you and all feedback is quite welcome.

Actually, my local script calls two C++ programs to accomplish what the provided one does. I think I can speed up the posted script by better use of arrays, though. I plan to do some study in that direction before I work much more with the C++ programs, although I'm sure a fully C++ program would still be considerably faster.

 Similar Threads Thread Thread Starter Forum Replies Last Post fivemack FactorDB 46 2021-02-21 10:46 schickel FactorDB 18 2013-06-12 16:09 garambois Aliquot Sequences 34 2012-06-10 21:53 Andi47 FactorDB 21 2011-12-29 21:11 schickel mersennewiki 0 2008-12-30 07:07

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

Fri May 7 08:20:35 UTC 2021 up 29 days, 3:01, 0 users, load averages: 2.40, 1.81, 1.66