/* Descending primes (Rosetta code) in Picat. http://rosettacode.org/wiki/Descending_primes """ Generate and show all primes with strictly descending decimal digits. """ This program was created by Hakan Kjellerstrand, hakank@gmail.com See also my Picat page: http://www.hakank.org/picat/ */ import util. main => go. go => DP = [N : S in power_set("987654321"), S != [], N = S.to_int, prime(N)].sort, foreach({P,I} in zip(DP,1..DP.len)) printf("%9d%s",P,cond(I mod 10 == 0,"\n","")) end, nl, foreach(P in DP) printf("%9d%s",P,cond(P mod 10 == 3,"\n","")) end, nl, println(len=DP.len), nl.