Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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