HOBBIES REPO
WELCOME TO MY HOBBIES REPO
UNUSEFUL codes are stored in this repository.
https://heishi1humanity.github.io/HobbiesRepo/
WAVES
PRIME NUMBER
MATH
- GCD
This function is based on Euclidean Algorithm.
- Convert Dec to Bin
This function return 8 digit binary number from decimal.
- Determinant
This function solve the determinant and return the answer.
- Newton’s Method
This function return √(argument).
tips: Newton’s method can find x which f(x) = 0.
- Statistics
This file are written some basic statistics function.(mean/deviation/variance/stdev)
PI
- Gauss Legendre Algorithm
- initial value
a0 = 1
b0 = 1 / √2
t0 = 1 / 4
p0 = 1
- repeat
an+1 = (an + bn) / 2
bn+1 = √(anbn)
tn+1 = tn - pn(an - an+1)2
pn+1 = 2pn
- pi is
π ≈ (an+1 + bn+1)2 / 4tn+1
- Leibniz Formula
∑[n=0→∞] (-1)n / 2n + 1 = π / 4
- Monte Carlo Method
X = number of points are x2 + y2 ≤ 1
N = number of total
π ≈ 4X / N
Math.max() VS Array.prototype.reduce()
Math.max() VS Array.prototype.reduce()
If you want to find out the largest number from array, you can use Math.max(...array). However this function can’t work if the array is so big. If you need to find out the largest number from big array, you should use array.reduce((a,b) => (a > b) ? a : b). This file compare the speed of Math.max() with the speed of Array.prototype.reduce().
Text Encrypter(TEST)
link is here
Text Encrypter
Now, Salsa20 / ChaCha20 is available