NextPrime[5, {-1, 2, 1, 0}]
NextPrime[5, {-1, 2, 1}]
Have a look at the results. It seems NextPrime produces strange results if its first argument is a prime number and the second argumetn is a list of both positive and negative integers
NextPrime[5, {-1, 2, 1, 0}]
NextPrime[5, {-1, 2, 1}]
Have a look at the results. It seems NextPrime produces strange results if its first argument is a prime number and the second argumetn is a list of both positive and negative integers
Even though the help pages don’t seem to mention it, the second argument to NextPrime can be a list. If a positive integer in that list is n then Next prime finds the n’th prime after the first argument, if it is negative then it finds the n’th prime before the first argument. So for your first example it finds the first prime before 5 = 3, the second prime after 5 = 11, the first prime after 5 = 7 and the zeroth prime after 5 = 5.
Is there anything wrong with this description or the help page description?
I agree with Gregory Fridman, the behaviour with a list is not consistent with NextPrime[n,#]&/@list.
To be specific:
NextPrime[5, {-1, 2, 1, 0}]
yields: {3, 11, 7, 5}
However:
NextPrime[5, {-1, 2, 1}]
yields: {3,7,5} where {3, 11,7} would be expected if the function was mapped to each list member or if it was recursive (e,g, Rest@FoldList[NextPrime[#1, #2] &, 5, {-1, 2, 1}]) viz nested {3,7,11}.
Similarly:
NextPrime[5, {-1, 1, 1, 1}]
yields: {3, 5, 5, 5} instead of the expected {3,7,7,7}.
I guess it does not handle list as second argument but also does not throw out.
Bill, the point is that the next cell gives different results. Have a look
NextPrime[5, {-1, 2, 1}]
This one giving {3,7,5} is a clear problem. Will investigate like, right now.
Thank you for the prompt reply