Munchausen numbers: Difference between revisions

Content added Content deleted
m (→‎{{header|Ring}}: Remove vanity tags)
(Add Swift)
Line 1,453:
[1, 3435]
</pre>
 
=={{header|Swift}}==
<lang swift>import Foundation
 
func isMünchhausen(_ n: Int) -> Bool {
let nums = String(n).map(String.init).compactMap(Int.init)
 
return Int(nums.map({ pow(Double($0), Double($0)) }).reduce(0, +)) == n
}
 
for i in 1...5000 where isMünchhausen(i) {
print(i)
}</lang>
{{out}}
<pre>1
3435</pre>
 
=={{header|VBA}}==