Skip to content

Instantly share code, notes, and snippets.

View michaelcontento's full-sized avatar

Michael Contento michaelcontento

View GitHub Profile
@michaelcontento
michaelcontento / prime_neighbours.sh
Created January 21, 2011 10:16
Detect prime twins in bash
#!/usr/bin/env bash
START=2
STOP=300
lastprime=2
primes=$(wget -O - -q http://www.math.utah.edu/~alfeld/math/p10000.html \
| cut -c8- \
| egrep -o '^ [0-9 ]+$' \
| awk '{ list = list $0 } END { print list }')
@michaelcontento
michaelcontento / prime_neighbours.py
Created January 20, 2011 14:35
Detect prime twins in python
#!/usr/bin/env python
from itertools import izip, tee
from sys import argv, exit
def pairwise(iter):
# See: http://docs.python.org/library/itertools.html#recipes
a, b = tee(iter)
next(b, None)
return izip(a, b)