cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Stay updated on what is happening on the PTC Community by subscribing to PTC Community Announcements. X

Twin Primes and Extracting.

lvl107
20-Turquoise

Twin Primes and Extracting.

Hi,

I have a question and need help. Assuming that we have a set of Prime Numbers (from 5 to 37

in this case) Let's extract Twin Primes like as the Output below. (IN .MCD12)

P.PNGTwinPrimes.PNG

Thanks in advance.

Regards,

Loi.

64 REPLIES 64

Mike Armstrong wrote:

Like the attached?

Mike

Message was edited by: Mike Armstrong - Worksheet saved down. The pre-defined function used is in the collasped area.

Mike,

Just a quick note. In my later worksheets, I've dropped the term 'ravel' and replaced it with 'vec'.

'ravel' is a term, that as far as I can determine, was first widely used in the programming language APL and has continued on into APL's 'successor', J, and some other vector languages. However, 'vec' appears to be more widely used in matrix theory and linear algebra. Given that the idea of Mathcad is to be an Engineer's, Scientist's, Mathematician's whiteboard, I thought I'd switch from ravel to vec.

Initially, I used vec as a general purpose function for integer sequences if the input was a scalar. However, as time went on, I thought it was more consistent to get vec to change a scalar into a single-element array and introduce the function 'seq' to generate sequences. Currently, the only difference between vec and seq is in the handling of scalars, but I might have a think about seq to see if I can make it more useful for sequence generation ... I've already created a few variants that handle different data types and more complex sequences.

Stuart

The attached worksheet has some behavioural differences between versions of Mathcad. M13..M15 will handle an expression of the form v:=vec(rv) where rv is a range variable, M11 won't. M11, M13..M15 will handle v:=vec(rd) where rd is a range definition (ie, expression of form a,b..c).

Very nice. Particulary like the seq(n) function.

I have been using the following function posted by Richard, but your seq function seems to have the advantage of taking a scalar.

Clipboard01.gif

Been having a think and I've got no idea how you could improve the seq function.

Mike

Mike Armstrong wrote:

Very nice. Particulary like the seq(n) function.

I have been using the following function posted by Richard, but your seq function seems to have the advantage of taking a scalar.

Clipboard01.gif

Been having a think and I've got no idea how you could improve the seq function.

Mike

OK. What's one of the annoyances you've got with the limitations of range variables? What data types can't you express as a range?

I'll see if I can dig up the worksheet I was working on a bit ago.

Stuart

OK. What's one of the annoyances you've got with the limitations of range variables? What data types can't you express as a range?

Is that a rhetorical question?

Mike

Mike Armstrong wrote:

OK. What's one of the annoyances you've got with the limitations of range variables? What data types can't you express as a range?

Is that a rhetorical question?

Mike

Do I look like a rhetorical kind of guy? I'm much too simple to indulge in rhetoric.

Think about the kind of sequences that a range variable generates. Are there any sequences you'd like to generate that you can't? Or any that Mathcad should be able to generate but can't? Eg, data types?

Stuart

Announcements

Top Tags