Skip to content

Instantly share code, notes, and snippets.

View eliannelavoie's full-sized avatar

Élianne Lavoie eliannelavoie

View GitHub Profile
const { performance } = require('perf_hooks')
let iterations = 250;
let sizes = [10, 100, 1000, 1000000];
let loopMethods = {
'while': iterWhile,
'for': iterFor,
'forEach': iterForEach,
'forOf': iterForOf
}
from math import sqrt
def isPentagonal(n):
return (1/6*(sqrt(24*n+1)+1)).is_integer()
i = 40756
while True:
h = i*(2*i-1)
if (isPentagonal(h)):
print(h)
from math import sqrt
from itertools import combinations
def isP(n):
return (1/6*(sqrt(24*n+1)+1)).is_integer()
p = [n*(3*n-1)/2 for n in range(1,2500)]
for x in combinations(p, 2):
if (isP(x[0]+x[1]) and isP(x[1]-x[0])):