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 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 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
for (i of [2, 3, 5, 7, 11, 13, 17, 19]) { | |
input_block = parseInt((Math.sqrt(i) % 1).toString(2).slice(2, 34), 2); | |
console.log(input_block.toString(16), input_block.toString(2).padStart(32, '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
'use strict'; | |
(function (shs) { | |
const H0 = [ | |
0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a, 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19, | |
]; | |
const K = [ | |
0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5, |
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
"""A class for one-neuron nets.""" | |
# -*- coding: utf-8 -*- | |
from __future__ import division | |
import numpy as np | |
class OneNeuronNet(object): | |
"""A neural network with a single neuron (but many incoming dendrons), for | |
experiments with different activation functions, cost functions and training | |
objectives.""" |
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
import numpy as np | |
def get_primes(n): | |
"""Returns a list of primes < n | |
https://stackoverflow.com/questions/2068372/fastest-way-to-list-all-primes-below-n | |
""" | |
sieve = [True] * n | |
for i in range(3, int(n ** 0.5) + 1, 2): | |
if sieve[i]: | |
sieve[i * i :: 2 * i] = [False] * ((n - i * i - 1) // (2 * i) + 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
from math import gcd | |
def test_property(candidate: int, max_progression: int=100): | |
"""Returns True if Fermat's little theorem's property is verified for a | |
limited number of progressions.""" | |
test_progressions = range(2, max_progression) | |
for progression in range(2, max_progression): | |
if gcd(progression, candidate) != 1: | |
# THIS IS DIFFERENT |
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
from matplotlib import pyplot as plt | |
# http://oeis.org/wiki/Carmichael_numbers | |
CARMICHAEL_NUMBERS = [ | |
561, 1105, 1729, 2465, 2821, 6601, 8911, 10585, 15841, 29341, 41041, 46657, | |
52633, 62745, 63973, 75361, 101101, 115921, 126217, 162401, 172081, 188461, | |
252601, 278545, 294409, 314821, 334153 | |
] | |
def prime_factors(n): |
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
import numpy as np | |
from matplotlib import pyplot as plt | |
def plot_little_fermat(height, width, overlay_primes=False): | |
"""Plot a^(q-1) for ranges of integers a, q.""" | |
# Compute the values | |
array = np.zeros([height, width]) | |
for i in range(height): |