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$
1
  • 2
    $\begingroup$ Differences[Table[Prime[i], {i, 1, 10}]] $\endgroup$
    – bill s
    Commented Jul 11, 2018 at 1:47

1 Answer 1

3
$\begingroup$

Here is the one way to do it.

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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