Define a function that checks whether a given number is prime. Your primal check does not have to be efficient; any algorithm you can think of will do. In case you have forgotten, a prime number is a natural number strictly greater than 1 and with no positive divisors other than 1 and itself. Write another function that generates a vector with all natural numbers less or equal to a first number and starting from another. By default it should start from 1. Create a third function that given a vector of numbers outputs another vector containing all the prime numbers it found in its input. Use these three functions to create a program that prints out all prime numbers less or equal to a number chosen by the user (print, for instance, 15 primes per line). Note: In principle, you do not need any vectors to print these prime numbers; obviously, these extra functions have been added for the sake of the exercise.
Already registered? Login
Not Account? Sign up
Enter your email address to reset your password
Back to Login? Click here