Skip to content

Instantly share code, notes, and snippets.

@stephen-hill
Last active August 29, 2015 14:06
Show Gist options
  • Save stephen-hill/60ead6d9594c48156b49 to your computer and use it in GitHub Desktop.
Save stephen-hill/60ead6d9594c48156b49 to your computer and use it in GitHub Desktop.
php-rsa
<?php
# Code ported from http://code.activestate.com/recipes/578838-rsa-a-simple-and-easy-to-read-implementation/
function getPrimes($start, $stop)
{
$primes = array(2);
$range = range(3, $stop + 1, 2);
foreach ($range as $n) {
foreach($primes as $p) {
if ($n % $p === 0) {
break;
}
}
$primes[] = $n;
}
var_dump($primes);
}
getPrimes(10, 1000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment