mersenneforum.org

mersenneforum.org (https://www.mersenneforum.org/index.php)
-   Aliquot Sequences (https://www.mersenneforum.org/forumdisplay.php?f=90)
-   -   Aliquot sequences that start on the integer powers n^i (https://www.mersenneforum.org/showthread.php?t=23612)

EdH 2021-02-14 17:07

[QUOTE=RichD;571589]@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...[/QUOTE]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.

garambois 2021-02-14 18:12

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 !

EdH 2021-02-14 23:02

[QUOTE=garambois;571594]. . .
Edwin, I hope I can use the script you are going to send us ![/QUOTE]
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. . .

EdH 2021-02-15 01:23

1 Attachment(s)
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
[/code]

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 "OE_3000000_C80.txt not found! Retrieve it from:"
echo "http://www.aliquotes.com/OE_3000000_C80.txt?"
printf "(y/[n]): "
read retyn in
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"
while read line0
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"
[/code]The script is also attached below.

Happy5214 2021-02-15 01:36

[QUOTE=EdH;571614]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.][/QUOTE]

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.

EdH 2021-02-15 02:18

[QUOTE=Happy5214;571615]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.[/QUOTE]
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.

Edit: OK, I added the option to download the 80 digit file. . .

Thanks for all the help, Happy5214!

EdH 2021-02-15 13:34

Anyone who has looked at my script for Aliquot merges, please see the note in the [URL="https://www.mersenneforum.org/showpost.php?p=571614&postcount=785"]original post[/URL]. Any assistance would be appreciated.

Happy5214 2021-02-15 13:49

[QUOTE=EdH;571648]Anyone who has looked at my script for Aliquot merges, please see the note in the [URL="https://www.mersenneforum.org/showpost.php?p=571614&postcount=785"]original post[/URL]. Any assistance would be appreciated.[/QUOTE]
All of the lines in the code block have trailing spaces.

EdH 2021-02-15 14:09

[QUOTE=Happy5214;571649]All of the lines in the code block have trailing spaces.[/QUOTE]Thank You! For all but one line, it probably wouldn't matter, but:
[code]
IFS='
'
[/code]was truly corrupted.

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

Much appreciated!

garambois 2021-02-15 17:40

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.

EdH 2021-02-15 18:32

[QUOTE=garambois;571665]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.[/QUOTE]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.


All times are UTC. The time now is 23:01.

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