Hello i'm trying to write a program in python to figure fence posts.

Im trying to decipher on this web page Wood Fence Calculator by Hoover Fence Co. how they come up with such an acurite answer.

I tried everything i took the total fence length of 190' divided it by 8 because that's the post spacing, then added the amount of coners lets say 4, and 2 end posts and 1 gate posts and i get it to give the correct answer i'm sure i'm doing something wrong. If you can punch in the web site and use the numbers i posted maybe you can give me a math expression how to go about it.

Just on the fence posts thanks