Blum integer: Difference between revisions

no edit summary
(New post.)
imported>Maxima enthusiast
No edit summary
Line 744:
end
</syntaxhighlight>{{out}} Same as Wren, Go, etc
 
=={{header|Maxima}}==
<syntaxhighlight lang="maxima">
/* Predicate functions that checks wether an integer is a Blum integer or not */
blum_p(n):=lambda([x],length(ifactors(x))=2 and unique(map(second,ifactors(x)))=[1] and mod(ifactors(x)[1][1],4)=3 and mod(ifactors(x)[2][1],4)=3)(n)$
 
/* Function that returns a list of the first len Blum integers */
blum_count(len):=block(
[i:1,count:0,result:[]],
while count<len do (if blum_p(i) then (result:endcons(i,result),count:count+1),i:i+1),
result)$
 
/* Test cases */
/* First 50 Blum integers */
blum_count(50);
 
/* Blum integer number 26828 */
last(blum_count(26828));
</syntaxhighlight>
{{out}}
<pre>
[21,33,57,69,77,93,129,133,141,161,177,201,209,213,217,237,249,253,301,309,321,329,341,381,393,413,417,437,453,469,473,489,497,501,517,537,553,573,581,589,597,633,649,669,681,713,717,721,737,749]
 
524273
</pre>
 
=={{header|Nim}}==