+ 1
Testing your code
After writing a code, especially a math or counting code, how do I test the code? Please provide an exemplary code if you will.
4 Answers
+ 4
find someone who will do it for u.
u might be blind a be in a certain pattern.
+ 1
You test it by creating desired inputs and solving the problems by hand then plug those inputs into your code and if they give the same outputs then your code is probably good, if not you would need to debug your code step by step ensuring you have the same results per your actual work done to determine where it is getting off track, ideally every line of code you would want to test as you go to ensure structural integrity during creation as opposed to praying that it works on your finished product
+ 1
A lot of the assignments here go like this, right? 'Check if n is prime', voodoo prime, Mersenne prime or whatever.
Normally you find a list of, let's say, voodoo primes between 1 and 1000, somewhere on the internet.
Now you can run your code over that range of numbers using a for loop, and compare the results with the list you've found.
(If there's no list, you're on your own and need to create a compare table by hand. )