You are given a function 'secret()' that accepts a single integer parameter and returns an integer. In your favorite programming language, write a command-line program that takes one command-line argument (a number) and determines if the secret() function is additive [secret(x+y) = secret(x) + secret(y)], for all combinations x and y, where x and y are all prime numbers less than the number passed via the command-line argument. Describe how to run your examples. Please generate the list of primes without using built-in functionality.
How to run:
-
Visit https://repl.it/ByGK/4. Note that this link is essentially a duplicate of the coding-exercise.js file.
-
Click on the "run" button.
-
In the console, run the following command:
ce.areAllPairsAdditive(<param>);
Where
<param>
is the integer parameter of your choosing. Additionally, after running the above command, you can run the following command:ce._primes;
to see the list of primes.