Narcissistic decimal number: Difference between revisions
Content added Content deleted
(Added Befunge example.) |
|||
Line 3,268: | Line 3,268: | ||
elapsed: 436.639</pre> |
elapsed: 436.639</pre> |
||
=={{header|VBA}}== |
|||
{{trans|Phix}}<lang vb>Private Function narcissistic(n As Long) As Boolean |
|||
Dim d As String: d = CStr(n) |
|||
Dim l As Integer: l = Len(d) |
|||
Dim sumn As Long: sumn = 0 |
|||
For i = 1 To l |
|||
sumn = sumn + (Mid(d, i, 1) - "0") ^ l |
|||
Next i |
|||
narcissistic = sumn = n |
|||
End Function |
|||
Public Sub main() |
|||
Dim s(24) As String |
|||
Dim n As Long: n = 0 |
|||
Dim found As Integer: found = 0 |
|||
Do While found < 25 |
|||
If narcissistic(n) Then |
|||
s(found) = CStr(n) |
|||
found = found + 1 |
|||
End If |
|||
n = n + 1 |
|||
Loop |
|||
Debug.Print Join(s, ", ") |
|||
End Sub</lang>{{out}} |
|||
<pre>0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 153, 370, 371, 407, 1634, 8208, 9474, 54748, 92727, 93084, 548834, 1741725, 4210818, 9800817, 9926315</pre> |
|||
=={{header|VBScript}}== |
=={{header|VBScript}}== |
||
<lang vb>Function Narcissist(n) |
<lang vb>Function Narcissist(n) |