Data update
This commit is contained in:
parent
4d5544505c
commit
4924dd0264
3073 changed files with 55820 additions and 4408 deletions
30
Task/Munchausen-numbers/ArkScript/munchausen-numbers.ark
Normal file
30
Task/Munchausen-numbers/ArkScript/munchausen-numbers.ark
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
(import std.List)
|
||||
|
||||
(let self-exponent (fun (x n acc)
|
||||
(if (> n 0)
|
||||
(self-exponent x (- n 1) (* x acc))
|
||||
acc)))
|
||||
|
||||
(let cache (list:map (list:iota 0 10) (fun (x) (if (= x 0) 0 (self-exponent x x 1)))))
|
||||
|
||||
(let is_munchausen (fun (number) {
|
||||
(mut total 0)
|
||||
(mut n number)
|
||||
(mut continue true)
|
||||
|
||||
(while (and (> n 0) continue) {
|
||||
(let digit (mod n 10))
|
||||
(set total (+ total (@ cache digit)))
|
||||
(if (> total number)
|
||||
(set continue false)
|
||||
(set n (math:floor (/ n 10)))) })
|
||||
|
||||
(= total number) }))
|
||||
|
||||
(let max_val 5000)
|
||||
|
||||
(mut i 1)
|
||||
(while (< i max_val) {
|
||||
(if (is_munchausen i)
|
||||
(print i))
|
||||
(set i (+ 1 i)) })
|
||||
Loading…
Add table
Add a link
Reference in a new issue