Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # A quick script to find the largest product of five consecutive digits
- # Set up our variables
- DIGIT_STR=73167176519225119674426574742355349194934969239574788518438581294949595833471852952276689664452316173111217223831136222989343362766144866452382712188399827466572785224352586415722155397536978179778451693219784686224828397224137968652142124122758866688116427171479924442965674813919123162824586178664583591245665294765456828489128836321655444362979927244913387599116983572972571636269561852
- POSITION=0
- LEN=5
- z=10000
- echo We have ${#DIGIT_STR} digits to process
- # Let's pull out our five digit substrings
- # Code samples:
- # z=`expr substr $string $position $length`
- # echo ${DIGIT_STR:0:5}
- # let "var += 5"
- # TEST=`echo "76843" | grep -o . | sort -nr | tr -d '\n'`
- while ((z >= 10000 ))
- do
- {
- z=${DIGIT_STR:$POSITION:$LEN}
- let "POSITION += 1"
- echo $z | grep -o . | sort -nr | tr -d '\n'
- echo
- }
- done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement