mersenneforum.org  

Go Back   mersenneforum.org > Factoring Projects > Aliquot Sequences

Reply
 
Thread Tools
Old 2021-02-14, 17:07   #782
EdH
 
EdH's Avatar
 
"Ed Hall"
Dec 2009
Adirondack Mtns

29×139 Posts
Default

Quote:
Originally Posted by RichD View Post
@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.
EdH is offline   Reply With Quote
Old 2021-02-14, 18:12   #783
garambois
 
garambois's Avatar
 
"Garambois Jean-Luc"
Oct 2011
France

68110 Posts
Default

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 !
garambois is online now   Reply With Quote
Old 2021-02-14, 23:02   #784
EdH
 
EdH's Avatar
 
"Ed Hall"
Dec 2009
Adirondack Mtns

1111101111112 Posts
Default

Quote:
Originally Posted by garambois View Post
. . .
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. . .
EdH is offline   Reply With Quote
Old 2021-02-15, 01:23   #785
EdH
 
EdH's Avatar
 
"Ed Hall"
Dec 2009
Adirondack Mtns

29×139 Posts
Default

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 "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"
The script is also attached below.
Attached Files
File Type: txt alimerge3.sh.txt (4.3 KB, 35 views)

Last fiddled with by EdH on 2021-02-15 at 14:03
EdH is offline   Reply With Quote
Old 2021-02-15, 01:36   #786
Happy5214
 
Happy5214's Avatar
 
"Alexander"
Nov 2008
The Alamo City

3×11×23 Posts
Default

Quote:
Originally Posted by EdH View Post
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.
Happy5214 is offline   Reply With Quote
Old 2021-02-15, 02:18   #787
EdH
 
EdH's Avatar
 
"Ed Hall"
Dec 2009
Adirondack Mtns

29·139 Posts
Default

Quote:
Originally Posted by Happy5214 View Post
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.

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

Thanks for all the help, Happy5214!

Last fiddled with by EdH on 2021-02-15 at 03:21 Reason: Reason provided above
EdH is offline   Reply With Quote
Old 2021-02-15, 13:34   #788
EdH
 
EdH's Avatar
 
"Ed Hall"
Dec 2009
Adirondack Mtns

29×139 Posts
Default

Anyone who has looked at my script for Aliquot merges, please see the note in the original post. Any assistance would be appreciated.
EdH is offline   Reply With Quote
Old 2021-02-15, 13:49   #789
Happy5214
 
Happy5214's Avatar
 
"Alexander"
Nov 2008
The Alamo City

3×11×23 Posts
Default

Quote:
Originally Posted by EdH View Post
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.
Happy5214 is offline   Reply With Quote
Old 2021-02-15, 14:09   #790
EdH
 
EdH's Avatar
 
"Ed Hall"
Dec 2009
Adirondack Mtns

76778 Posts
Default

Quote:
Originally Posted by Happy5214 View Post
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!
EdH is offline   Reply With Quote
Old 2021-02-15, 17:40   #791
garambois
 
garambois's Avatar
 
"Garambois Jean-Luc"
Oct 2011
France

3·227 Posts
Default

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.
garambois is online now   Reply With Quote
Old 2021-02-15, 18:32   #792
EdH
 
EdH's Avatar
 
"Ed Hall"
Dec 2009
Adirondack Mtns

76778 Posts
Default

Quote:
Originally Posted by garambois View Post
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.
EdH is offline   Reply With Quote
Reply

Thread Tools


Similar Threads
Thread Thread Starter Forum Replies Last Post
Broken aliquot sequences fivemack FactorDB 46 2021-02-21 10:46
Broken aliquot sequences schickel FactorDB 18 2013-06-12 16:09
A new theorem about aliquot sequences garambois Aliquot Sequences 34 2012-06-10 21:53
poaching aliquot sequences... Andi47 FactorDB 21 2011-12-29 21:11
New article on aliquot sequences schickel mersennewiki 0 2008-12-30 07:07

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


Tue Oct 26 19:23:04 UTC 2021 up 95 days, 13:52, 0 users, load averages: 2.33, 2.71, 2.68

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.