Last active
July 28, 2019 15:46
-
-
Save dardo82/045931b9f84f31332ad0 to your computer and use it in GitHub Desktop.
Conjecture proof scripts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env zsh | |
zmodload zsh/mathfunc | |
setopt extended_glob | |
BN="${${0##*/}%%.*}" | |
{ | |
NC=(1) | |
echo "strict digraph collatz {" | |
for n in {2..$1}; do | |
if [ ! ${NC[(r)$n]} ]; then | |
echo -n "$n " | |
NC=($n;$NC) | |
else | |
continue | |
fi | |
while [ $n != 1 ]; do | |
if [ $[$n%2] = 0 ]; then | |
n=$[$n/2] | |
else | |
n=$[(3*$n)+1] | |
fi | |
if [ ! ${NC[(r)$n]} ]; then | |
echo -n "-> $n " | |
NC=($n;$NC) | |
else | |
echo "-> $n;" | |
break | |
fi | |
done | |
done | |
echo | |
for nc in $NC; do | |
if [ ! $[$nc%2] = 0 ]; then | |
k=$[log2($nc+1)] | |
if [ ! ${k#*.} ]; then | |
c="$[ceil($k)]" | |
if [ $[${c%.*}%2] = 0 ]; then | |
S="doublecircle" | |
else | |
S="circle" | |
fi | |
else | |
S="ellipse" | |
fi | |
else | |
k=$[log2($nc+1)/log2(3)] | |
if [ ! ${k##*.(0##??)#} ]; then | |
S="square" | |
else | |
S="rectangle" | |
fi | |
fi | |
echo "$nc [shape=$S];" | |
done | |
echo "}" | |
} > $BN.dot | |
dot -Tpdf:cairo $BN.dot > $BN.pdf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/zsh | |
# Sort the first 100 natural numbers by the lenght of the Collatz sequence that they generate. | |
function collatz () { setopt extended_glob; n=${1##0#}; echo -n "$n "; [[ $n == 1 ]] && return; n=${$(($1.0/2.0))%%.}; [ $(grep -F . <<< $n) ] && n=$((($1*3)+1)); collatz $n; n=0 } | |
for n in {001..100}; do echo -n "collatz($n): "; awk -F' ' '{print $0" #"NF}' <<< ${$(collatz $n)##0#}; done | sort -n -k2.1 -t\# | awk -F'[()]' '{gsub(/^0*/,"",$2); printf $2" "}' | |
# for N in {002..100}; do set -A COLLATZ $(collatz $N); float -F 10 Q=$(($(((${#$(([#2]$N))}-2)-1)).0/$((${#COLLATZ}-1)).0)); echo "$N: $Q"; done | sort -k 2.1 -t . | |
# for n in {1..1000}; do for i in $(eval printf '%s\\n' $(printf '{0,1}%.s' {1..3}) | grep -v 11); do while [ $n != 1 ]; do echo -n $[$n%2]; [ $[$n%2] = 0 ] && n=$[$n/2] || n=$[3*$n+1]; done | sed 's/$/1000/;s/.../&'\\$'\n'/g | sed -n '$!p' | grep -c $i; done; echo; done | rs -T | fold -w20 | awk '{S1+=$1;S2+=$2;S3+=$3;S4+=$4;S5+=$5} END{print S1" "S2" "S3" "S4" "S5}' | |
# for n in {1..10}; do eval printf '%s\\n' $(printf '{0,1}%.s' {1..$n}) | grep -v 11 | wc -l; done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/zsh | |
# http://vixra.org/pdf/1005.0025v1.pdf | |
setopt extended_glob; N=$1 | |
while [ ${N%%10#} ]; do | |
echo $N; N=$(echo {i,o}base=2\; \ | |
"$N*11+${N/${N%%10#}}" | bc); done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment