The values you quote are Nominal values, approximate values not necessarily actually existing, historically stated by humans to be sort of nice rounded numbers. As such, the nominal values are somewhat arbitrary, but convention over 100 years has standardized them to be your list.
But the cameras actually use more precise goal values, powers of 2.
Shutter speeds necessarily have to actually be powers of 2, each full stop being 2x intervals. So the precise values the camera actually uses are 1, 1/2, 1/4, 1/8, 1/16, 1/32, 1/64, 1/128, 1/256, 1/512, 1/1024, etc. Humans just sort of instead call them rounded approximate names. But math and calculation must use the precise values.
Your camera might have a 15 or 30 second shutter speed (nominal), but if you time it, it will be 16 or 32 seconds (precise). If it were only 15 or 30 seconds, it would NOT be a precise 2x stop, and the plan would go astray.
These actual precise values are generated by 2 to power of stop number (0, 1, 2, 3, 4, etc), with all fractional values being a negative exponent. Fstops are a positive exponent of square root of 2.
Third stops are the sequence of stop numbers 0, 0.3333, 0.6667, 1, 1.3333, 1.6667, 2, etc.
for (i = 5; i > -10; i -= 1/3) { // thirds for 32 second to 1/1024 second
value = Math.pow(2, i);
}
These are the precise goals actually used, not the approximate nominal numbers as we imagine them.
My site has much more about this at
https://www.scantips.com/lights/fstop2.html
(bottom part of that page is about calculation)