Sub SumPower() Dim n As Integer Dim i As Integer Dim sum As Double
n = InputBox("Enter a number:") If n < 1 Then MsgBox "Please enter a positive integer" Exit Sub End If sum = 0 For i = 1 To n sum = sum + i ^ (i - 1) Next i MsgBox "The sum is: " & sum
Sub SumPower()
n = InputBox("Enter a number:")Dim n As Integer
Dim i As Integer
Dim sum As Double
If n < 1 Then
MsgBox "Please enter a positive integer"
Exit Sub
End If
sum = 0
For i = 1 To n
sum = sum + i ^ (i - 1)
Next i
MsgBox "The sum is: " & sum
End Sub