// Solver for Rosetta Code problem: // https://rosettacode.org/wiki/Strange_unique_prime_triplets // // This is a good test of the multifor statement where one value relies on // values to its left, including torture-testing the cases where a lot of // backtracking is required. This did not work right until 2025-04-12. strangePrimes[max, print=false] := { count = 0 multifor [n,m,p] = [primes[2,max], primes[n+1,max], primes[m+1,max]] { sum = n + m + p if isPrime[sum] { count = count + 1 if print println["$n + $m + $p = $sum"] } } println["Found $count unique strange prime triplets up to $max"] } strangePrimes[30, true] strangePrimes[1000, false]