This is the code which I wrote with For loop to caculate Exponent..
It can be listed pow 1, pow2...,etc
Noraml Forloop ver.
And this is the Recursion for caculating Exponent..
But how can I list each pow in Recursion ver. as For loop ver.
Recursion ver.
It can be listed pow 1, pow2...,etc
Noraml Forloop ver.
[ autoit ]
$x = InputBox("Power", "Base:") $y = InputBox("Power", "Exponent:") MsgBox(0, "", powFor($x, $y)) Func powFor($x, $y) Dim $n, $t = $x, $c = 1, $p = 0 If $y == 0 Then Return 1 ElseIf $y < 0 Then For $i = StringRegExpReplace($y, '-(\d+)', '$1') To 1 Step - 1 If $c = 1 Then $x *= 1 $c += 1 $p += 1 $n &= "p" & $p & " : " & (1 / $x) & @CRLF Else $x *= $t $p += 1 $n &= "p" & $p & " : " & (1 / $x) & @CRLF EndIf Next Else For $i = $y To 1 Step - 1 If $c == 1 Then $x *= 1 $c += 1 $p += 1 $n &= "p" & $p & " : " & $x & @CRLF Else $x *= $t $p += 1 $n &= "p" & $p & " : " & $x & @CRLF EndIf Next EndIf Return $n EndFunc
And this is the Recursion for caculating Exponent..
But how can I list each pow in Recursion ver. as For loop ver.
Recursion ver.
[ autoit ]