Jump to content

Munchausen numbers: Difference between revisions

No edit summary
Line 708:
</pre>
 
=={{header|vbscript}}==
<lang vbscript>
=={{header|vbscript}}==
<lang vbscript>
for i = 1 to 5000
if Munch(i) Then
Wscript.Echo i, "is a Munchausen number"
end if
next
 
Line 722 ⟶ 724:
Function Munch (num)
 
dim str: str = Cstr(num) 'input num as a string
dim sum: sum = 0 'running sum of n^n
dim i 'loop index
dim n 'extracted digit
 
for i = 1 to len(str)
n = CInt(Mid(str,i,1))
sum = sum + n^n
next
 
Munch = (sum = num)
 
End Function
Cookies help us deliver our services. By using our services, you agree to our use of cookies.