Deceptive numbers: Difference between revisions
Content added Content deleted
m (→{{header|Quackery}}: sped up rep) |
imported>Maxima enthusiast No edit summary |
||
Line 528: | Line 528: | ||
The 1000th is: 24279289</pre> |
The 1000th is: 24279289</pre> |
||
=={{header|Maxima}}== |
|||
<syntaxhighlight lang="maxima"> |
|||
/* Function for repunit numbers */ |
|||
repunit(n):=(10^n-1)/9; |
|||
/* Function that checks if property is satisfied */ |
|||
repunit_property(n):=is(mod(repunit(n-1),n)=0); |
|||
/* Function to list the first n deceptive numbers */ |
|||
deceptive_list(n):=block([deceptives:[],count:0,i:5], |
|||
while count<n do (if repunit_property(i) and not primep(i) then (push(i,deceptives),count:count+1),i:i+1), |
|||
reverse(deceptives)); |
|||
</syntaxhighlight> |
|||
{{out}} |
|||
<pre> |
|||
deceptive_list(10); |
|||
[91,259,451,481,703,1729,2821,2981,3367,4141] |
|||
</pre> |
|||
=={{header|Nim}}== |
=={{header|Nim}}== |