Calmo numbers: Difference between revisions

Add Mathematica/Wolfram Language implementation
m (→‎{{header|Wren}}: Changed to Wren S/H)
(Add Mathematica/Wolfram Language implementation)
Line 633:
println(filter(isCalmo, 1:1000))
</syntaxhighlight>
 
=={{header|Mathematica}}/{{header|Wolfram Language}}==
<syntaxhighlight lang="Mathematica">
(*Function to get the divisors of a number excluding 1 and the number itself*)
EligibleDivisors[n_Integer] :=
Select[Divisors[n], # != 1 && # != n &]
 
(*Function to check if the sum of every three consecutive eligible divisors is prime*)
IsCalmoNumber[n_Integer] :=
Module[{divisors, sums, divisorsLength},
divisors = EligibleDivisors[n];
divisorsLength = Length[divisors];
If[Mod[divisorsLength, 3] != 0 || divisorsLength <= 0,
Return[False]];
sums = Total /@ Partition[divisors, 3];
AllTrue[sums, PrimeQ]
]
 
(*Find all Calmo numbers under 1000*)
calmoNumbers = Select[Range[2, 999], IsCalmoNumber]
 
(*Output the Calmo numbers*)
calmoNumbers // Print
</syntaxhighlight>
{{out}}
<pre>
{165, 273, 385, 399, 561, 595, 665, 715, 957}
 
</pre>
 
=={{header|MiniScript}}==
337

edits