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
#!/usr/bin/env python | |
import os | |
from concurrent.futures import ProcessPoolExecutor | |
import math | |
import time | |
PRIMES = [ | |
112272535095293, | |
112582705942171, |
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
class enforce(object): | |
def __init__(self,*argtypes): | |
# the types that need to be enforced for each position arg[i] | |
self.argtypes = argtypes | |
def __call__(self,f): | |
def wrapper(*args): | |
# bail if the definition isn't set up to handle this many arguments | |
if len(self.argtypes) < len(args): | |
raise Exception('too many parameters passed in') |
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
/** | |
* This program shows the different kinds of calls that can be made for functions like the factorial, and fibonacci | |
* | |
*/ | |
public class FactorialExample { | |
public static void main(String[] args) { | |
System.out.println( factRecursive(5)); | |
System.out.println( factTailRecursive(5)); | |
System.out.println( factIterative(5)); |