Select primes from their Zeckendorf representation

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\}$$

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

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