1
$\begingroup$

I'm working with the Zeckendorf representation of prime numbers. I'm using

ResourceFunction["ZeckendorfRepresentation"][Prime[n]]

and I would like to select from all the results, the ones with this peculiar representation: an alternating sequence of $ 1 $ and $ 0 $ of various lenght, ending with two adjacent $ 0 $ and $ 1 $ (and eventually just various $ 0 $). As an example I want to select $ 607 $ because this is the representation:

$ \{1,0,1,0,1,0,1,0,1,0,0,1,0\} $

or $ 6763 $:

$ \{1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,0,1\} $

Or $ 679891411787178541 $

$\{1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0\}$

$\endgroup$

1 Answer 1

1
$\begingroup$

Something along these lines?

thePattern = {PatternSequence[1, 0] .., 0, 1, 0 ...};
MatchQ[ResourceFunction["ZeckendorfRepresentation"][607], thePattern]

True

MatchQ[ResourceFunction["ZeckendorfRepresentation"][6763], thePattern]

True

MatchQ[ResourceFunction["ZeckendorfRepresentation"][679891411787178541], thePattern]

True

UPDATE

If you want the primes themselves that satisfy this property:

primes = Array[Prime, 1000];
Select[primes, MatchQ[thePattern]@*ResourceFunction["ZeckendorfRepresentation"]]

{19, 31, 53, 131, 139, 607, 953, 1453, 2351, 2579, 6763}

If you want the zeckendorf representations:

primeZecks = Array[ResourceFunction["ZeckendorfRepresentation"]@*Prime, 1000];
Select[zeckendorfs, MatchQ[thePattern]]

Or, if you'll want both forms, then you could create pairs, or if you want ... etc etc etc

$\endgroup$
1
  • $\begingroup$ Yeah, thank you! Now if I want a Table of the primes with this representation, how should I use the Select command? $\endgroup$
    – user967210
    Feb 5, 2023 at 8:58

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.