2
$\begingroup$

I create a list of primes in table form... How do I generate and display the difference between the prime numbers in sequence?

In[1]:= Table[Prime[n], {n, 10}]
Out[1]= {2, 3, 5, 7, 11, 13, 17, 19, 23, 29}

expected output:

{1, 2, 2, 4, 2, 4, 2, 4, 6}

All help gratefully received.

$\endgroup$
  • 2
    $\begingroup$ Differences[Table[Prime[i], {i, 1, 10}]] $\endgroup$ – bill s Jul 11 '18 at 1:47
3
$\begingroup$

Here is the one way to do it.

Differences@Prime[Range@10]
$\endgroup$
  • $\begingroup$ Excellent - Thank you! Chuckle - I have once again confirmed I am an idiot. $\endgroup$ – Technophobe01 Jul 11 '18 at 1:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.