Data update
This commit is contained in:
parent
5af6d93694
commit
796d366b97
455 changed files with 7413 additions and 1900 deletions
22
Task/Disarium-numbers/Maxima/disarium-numbers.maxima
Normal file
22
Task/Disarium-numbers/Maxima/disarium-numbers.maxima
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
/* Function that returns a list of digits given a nonnegative integer */
|
||||
decompose(num) := block([digits, remainder],
|
||||
digits: [],
|
||||
while num > 0 do
|
||||
(remainder: mod(num, 10),
|
||||
digits: cons(remainder, digits),
|
||||
num: floor(num/10)),
|
||||
digits
|
||||
)$
|
||||
|
||||
disariump(n):=block(
|
||||
decompose(n),
|
||||
makelist(%%[i]^i,i,length(%%)),
|
||||
apply("+",%%),
|
||||
if n=%% then true)$
|
||||
|
||||
disarium_count(len):=block([i:0,count:0,result:[]],
|
||||
while count<len do (if disariump(i) then (result:endcons(i,result),count:count+1),i:i+1),
|
||||
result)$
|
||||
|
||||
/*Test cases */
|
||||
disarium_count(18);
|
||||
Loading…
Add table
Add a link
Reference in a new issue