Skip to content

Instantly share code, notes, and snippets.

@deniszh
Created August 7, 2014 14:49
Show Gist options
  • Save deniszh/d35be4c38b41a771fd7b to your computer and use it in GitHub Desktop.
Save deniszh/d35be4c38b41a771fd7b to your computer and use it in GitHub Desktop.
Google hiring task (first 10-digit prime in e) in bash
#!/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