Hey! Welcome to the site.
Thanks for your response here;
https://pokemondb.net/pokebase/243375/horde-encounter-shiny-chance?show=283868#a283868. I've hidden your answer since the question has been resolved already for a large period of time. Generally, don't answer questions that already have a Best Answer unless they are clearly wrong and you can explain why.
Also, generally speaking, shoving a line of code and saying "this is how I got it" is incomprehensible to most people. It'd be much simpler to explain it in terms of mathematical probability than shoving a line of JS.