Happy 5th birthday, Cody! Since 5 is a prime number, let's have some fun looking for other prime numbers.
Given a positive integer x, find the nearest prime number. Keep in mind that the nearest prime may be less than x.
Examples
nearestprime(5) = 5 nearestprime(36) = 37 nearestprime(200) = 199
NOTE: You may ignore cases in which two prime numbers are equally close to x. (e.g., x=12 --> 11 and 13 are both primes).
Test case No. 5
x = 911;
y_correct = 911;
Should the nearest prime number for 911 have been 907?
how i can solve
which is wrong
Look. It's Size 80
I feel for you, typing in those endless arrays of prime numbers.
You have probably figured it out by now, but instead of typing in manually the vectors prim0 and prim1 and then checking memberships, you can just run the function 'isprime(x)' which will save you lots of space and time
Compute a dot product of two vectors x and y
656 Solvers
632 Solvers
Number of digits in an integer
277 Solvers
269 Solvers
Is this triangle right-angled?
1448 Solvers