Calmo numbers: Difference between revisions

no edit summary
(→‎{{header|Quackery}}: replaced isprime not with factors size 2 !=)
imported>Chinhouse
No edit summary
Line 633:
println(filter(isCalmo, 1:1000))
</syntaxhighlight>
 
=={{header|MiniScript}}==
<syntaxhighlight lang="miniscript">
isPrime = function(n)
if n < 2 then return false
if n < 4 then return true
for i in range(2,floor(n ^ 0.5))
if n % i == 0 then return false
end for
return true
end function
 
getFactors = function(n)
factors = {}
for i in range(1, floor(n ^ 0.5))
if n % i == 0 then
factors[i] = 1
factors[n /i ] = 1
end if
end for
return factors.indexes.sort
end function
 
isCalmo = function(n)
factors = getFactors(n)
if not(factors.len >= 5 and (factors.len - 2) % 3 == 0) then return false
for i in range(1, factors.len - 4, 3)
if not isPrime(factors[i] + factors[i+1] + factors[i+2]) then return false
end for
return true
end function
 
for i in range(1, 1000)
if isCalmo(i) then print i
end for
</syntaxhighlight>
{{out}}
<pre>165
273
385
399
561
595
665
715
957
</pre>
 
=={{header|Nim}}==
Anonymous user