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
open List;; | |
open Printf;; | |
let rec dfact n = | |
match n with | |
0 -> 1 | |
| 1 -> 1 | |
| 2 -> 2 | |
| 3 -> 6 | |
| 4 -> 24 |
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
#load "nums.cma";; | |
open Big_int;; | |
open List | |
let p a n = | |
let rec p_inner acc m = | |
let pn k = | |
let an = big_int_of_int (nth a (k - 2)) | |
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
#!/usr/bin/python | |
n = 1 | |
b = 0 | |
def is_bouncy(n): | |
if len(str(n)) <= 2: | |
return False | |
l = map(int, str(n)) | |
inc = all(x <= y for x, y in zip(l, l[1:])) |
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 | |
from fractions import gcd | |
s = 4 | |
e = 12001 | |
nf = 0 | |
for d in xrange(s, e): |
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 | |
from libeuler import is_prime | |
def prime_factors(n, P): | |
r = [] | |
t = n | |
while True: | |
if t == 1: | |
break |
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
#load "euler.cma";; | |
open Euler;; | |
let pentagonal n = n * (3*n - 1) / 2;; | |
let pentagonal_index n = int_of_float ((1. +. sqrt(1. +. 24. *. float_of_int(n))) /. 6.);; | |
let is_pentagonal d = (mod_float ((sqrt(24. *. float_of_int(d) +. 1.) +. 1.) /. 6.) 1.) = 0.;; |
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 | |
from libeuler import str_permutations | |
if __name__ == '__main__': | |
nums = str_permutations('0123456789') | |
r = [] | |
for n in nums: | |
n1 = int(n[1:4]) | |
n2 = int(n[2:5]) |
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 | |
def period(n): | |
a_0 = int(n ** 0.5) | |
if a_0 * a_0 == n: | |
return 0 | |
b, b_0 = a_0, a_0 | |
c, c_0 = n - a_0*a_0, n - a_0*a_0 | |
res = 0 | |
while True: |
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/python | |
from operator import mul | |
from multiprocessing import Pool, Manager | |
manager = Manager() | |
primes_cache = manager.list() | |
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 coffee | |
path = require 'path' | |
fs = require 'fs' | |
util = require 'util' | |
hat = require 'hat' | |
argv = require('optimist') | |
.usage('Usage: $0 --name <deck name> --color <card color> <directory>') | |
.string(['name', 'color']) | |
.demand(1) |
OlderNewer