Created
August 7, 2014 14:49
-
-
Save deniszh/d35be4c38b41a771fd7b to your computer and use it in GitHub Desktop.
Google hiring task (first 10-digit prime in e) in bash
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/bash | |
N=1000 | |
e=$(BC_LINE_LENGTH=0 bc -l <<<"scale=$N;e(1)"|sed 's#\.##'g) | |
M=$((N-10)) | |
for i in $(seq 0 $M) | |
do | |
a="${e:$i:10}" | |
[ "$(factor $a | cut -d' ' -f2)" == "$a" ] && echo $a | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment