mersenneforum.org > EdH How I Create a Colab Session That Factors factordb Small Composites with PARI/GP
 Register FAQ Search Today's Posts Mark Forums Read

 2020-11-21, 17:12 #1 EdH     "Ed Hall" Dec 2009 Adirondack Mtns 1110100000012 Posts How I Create a Colab Session That Factors factordb Small Composites with PARI/GP (Note: I expect to keep the first post of each of these "How I..." threads up-to-date with the latest version. Please read the rest of each thread to see what may have led to the current set of instructions.) I will take the liberty of expecting readers to already be somewhat familiar with Google's Colaboratory sessions. There are several threads already on Colab and these should be reviewed by interested readers: Google Colaboratory Notebook? GPU72 Notebook Integration... Notebook Instance Reverse SSH and HTTP Tunnels. Colab question I do not, as of yet, have a github account, so I have not created an upload of this to github. Others may feel free to do so, if desired. The following is a manner to retrieve small composites from factordb.com and factor out small primes by TF using PARI/GP. This does not totally factor all composites that are encountered. Although it can be used with larger composites, it is not to be considered effective, unless those composites are comprised of many small primes. When run, this session retrieves composites of a chosen size from factordb, factors out small primes and submits the factors back to the db. To use Colab, you need a Gmail account and will be required to log into that account to run a session. On to the specifics: Open a Google Colaboratory session. Sign in with your Google/Gmail account info. Choose New Python3 notebook: Code: Menu->File->New Python3 notebook (or within popup) Click Connect to start a session. Edit title from Untitled... to whatever you like. Paste the following into the Codeblock: Code: ######################################################### ### This Colaboratory session is designed to retrieve ### ### small composites from factordb.com and factor them ## ### using PARI/GP. The factors are then sent back to ### ### factordb. ### ### ### ### To adjust the number of composites to retrieve as ### ### well as the size to retrive, change the variables ### ### totalrun and digitsize. The size of the random ### ### number to be used to help avoid collisions (1000) ### ### can also be changed, as well as the offset (10). ### ######################################################### !apt install pari-gp !echo '#!/bin/bash/' >dbW.sh !echo '' >>dbW.sh !echo 'digitsize=20' >>dbW.sh !echo 'totalrun=50' >>dbW.sh !echo '' >>dbW.sh !echo 'printf "\nFactoring $totalrun composites:\n\n"' >>dbW.sh !echo 'for ((n=0;n>dbW.sh !echo ' do' >>dbW.sh !echo ' startt=$SECONDS' >>dbW.sh !echo ' randomnumber=$(echo$((10 + RANDOM % 1000)))' >>dbW.sh !echo ' wget "http://factordb.com/listtype.php?t=3&mindig=${digitsize}&perpage=1&start=$randomnumber&download=1" -q -O dbTemp' >>dbW.sh !echo ' exec <"dbTemp"' >>dbW.sh !echo ' read composite in' >>dbW.sh !echo ' if [[ $composite =~ ^[0-9]+$ ]]' >>dbW.sh !echo ' then' >>dbW.sh !echo ' ccount=0' >>dbW.sh !echo ' echo "Composite $((${n}+1)) of $totalrun is$composite <${#composite}>"' >>dbW.sh !echo ' temp=$(echo "factor($composite, 10^9)" | gp -f -q)' >>dbW.sh !echo ' temp=$(echo "${temp//\n/}" | xargs)' >>dbW.sh !echo ' temp=$(echo "${temp// 1]/}")' >>dbW.sh !echo ' temp=$(echo "${temp//]/}")' >>dbW.sh !echo ' temp=$(echo "${temp//[/*}")' >>dbW.sh !echo ' temp=$(echo "${temp// /}")' >>dbW.sh !echo ' printf "Factors are${temp:1} <$((${SECONDS}-${startt}))s>\n\n"' >>dbW.sh !echo ' returnfactors=${composite}%3D${temp:1}' >>dbW.sh !echo ' wget "http://factordb.com/report.php?report=$returnfactors" -q -O dbSuccess' >>dbW.sh !echo ' else' >>dbW.sh !echo ' let ccount=${ccount}+1' >>dbW.sh !echo ' printf "Non-number found (${composite})! Pausing briefly. . .\n\n"' >>dbW.sh !echo ' if [ $ccount -gt 4 ]' >>dbW.sh !echo ' then' >>dbW.sh !echo ' sleep 590' >>dbW.sh !echo ' fi' >>dbW.sh !echo ' sleep 10' >>dbW.sh !echo ' fi' >>dbW.sh !echo ' done' >>dbW.sh !echo 'echo "Total time for$n composites was \$SECONDS seconds."' >>dbW.sh !echo 'rm dbTemp' >>dbW.sh !bash dbW.sh Click on the Run cell icon or use CTRL-Enter. The first time this is run, PARI/GP will be installed prior to writing the script to a file and running it. Subsequent runs within the same session check that PARI/GP is installed and then continue. The current default is to process fifty, 20 digit composites and stop. The factors are sent to the db automatically, so no other manual intervention is needed. To change the number of composites to work on for each run, edit the totalrun variable. To change the size of the composites to work on edit the digitsize variable. Choosing a size doesn't guarantee work on that size. It is only the minimum size to retrieve. This script will work with the smallest size available starting with the digitsize value. Eventually, I hope to add a more detailed description of all the code. Last fiddled with by EdH on 2020-11-21 at 17:20

 Similar Threads Thread Thread Starter Forum Replies Last Post hansl FactorDB 54 2020-11-25 23:31 EdH EdH 0 2019-12-07 19:51 EdH EdH 0 2019-12-04 01:49 EdH EdH 12 2019-11-11 17:44 Batalov Cunningham Tables 15 2011-07-30 03:43

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

Sun May 9 08:11:19 UTC 2021 up 31 days, 2:52, 0 users, load averages: 2.53, 2.67, 2.87