In this tutorial I will show you how important it is to read the documentation in programming.
I’ll start with a simple command to detect the go language version

Most will say there are improvements and it is normal to know them.
Some of them will think that implementation is not obvious at a more general level and does not affect basic issues.
Let’s continue with the following example:

Obviously the word “Probably” will ask us a question mark.
Here’s what the documentation tells us:

func (*Int) ProbablyPrime
func (x *Int) ProbablyPrime(n int) bool
ProbablyPrime reports whether x is probably prime, applying the Miller-Rabin test with n pseudorandomly chosen bases as well as a Baillie-PSW test.

If x is prime, ProbablyPrime returns true. If x is chosen randomly and not prime, ProbablyPrime probably returns false. The probability of returning true for a randomly chosen non-prime is at most ¼ⁿ.

ProbablyPrime is 100% accurate for inputs less than 2⁶⁴. See Menezes et al., Handbook of Applied Cryptography, 1997, pp. 145-149, and FIPS 186-4 Appendix F for further discussion of the error probabilities.

ProbablyPrime is not suitable for judging primes that an adversary may have crafted to fool the test.

As of Go 1.8, ProbablyPrime(0) is allowed and applies only a Baillie-PSW test. Before Go 1.8, ProbablyPrime applied only the Miller-Rabin tests, and ProbablyPrime(0) panicked.

About prime numbers:

When a number has more than two factors it is called a composite number. Here are the first few prime numbers: 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199

Although both Baillie-PSW test and Miller-Rabin tests, solve the same problem.
Knowing which version we have, we can see what is important for programming.
Also, the information like: ProbablyPrime is 100% accurate for inputs less than 2⁶⁴ are very important from a mathematical point of view.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.