JSFiddle - React, Tailwind, and code Playground
One way Backward Number Generator
by skibulk
JavaScript
console.clear();
var state = 128603759836;
for (var i = 0; i < 5; i++) {
state = next(state);
console.log(state);
}
for (var i = 0; i < 5; i++) {
// Left trim to 12 digits
state = state % Math.pow(10, 10);
state = prev(state);
console.log(state);
}
function next(n) {
n = Math.asin(n) + (2 * Math.PI);
// Move decimal far right
while (n % 1) {
n *= 10;
}
// Left trim to 12 digits
state = state % Math.pow(10, 10);
// Add Leading 2 Digits
var prepend = Math.floor(Math.random() * (89) + 10);
n += prepend * Math.pow(10, 10);
// Move decimal far left
while (n > 1) {
n /= 10;
}
return n;
}
function prev(n){
n = Math.sin(n);
while (n % 1) {
n *= 10;
}
return n;
}
/*
// 10^12 = 1000000000000
var min = Math.pow(10, 10);
var max = Math.pow(10, 12);
var target = Math.random() * (max - min) + min;
console.log(Math.pow(10, 12));
for (var i = 0; i < 5; i++) {
var n = Math.trunc(state / 100);
state = n;
console.log(state);
}
function prev(n){
n = Math.sin(n) * 10000;
n -= Math.floor(n);
while (n % 1) {
n *= 10;
}
return n;
}
*/