Root Of

Email
 Submitted on: 5/17/2018 7:11:08 AM By: Nicholas Forystek Level: Intermediate User Rating: Unrated Compatibility: VB 6.0 Views: 1176

'Find the root of a base number by any exponential number. Project->New, Standard EXE, Add Module, copy & paste this code into the new module, Project->Project1 Properties, change startup type to Sub Main(). Click okay and run.

code:
Can't Copy and Paste this?
 ``` '************************************** ' Name: Root Of ' Description:'Find the root of a base number by any exponential number. Project->New, Standard EXE, Add Module, copy & paste this code into the new module, Project->Project1 Properties, change startup type to Sub Main(). Click okay and run. ' By: Nicholas Forystek '************************************** 'Find the root of a base number by any exponential number. 'Project->New, Standard EXE, Add Module, copy & paste this 'code into the new module, Project->Project1 Properties, 'change startup type to Sub Main(). Click okay and run. 'Output will look like this in the intermediate window 'if you hit enter on the lines with the question marks ' '4/^256=4 '?4 ^ 4 ' 256 '2/^823543=907.492699695155 '?907.4929 ^2 ' 823543.36355041 ' '2/^56=7.48331477354788 '?7.50001 ^ 2 ' 56.2501500001 ' '2/^3283=57.2974694031072 '?57.3 ^ 2 ' 3283.29 ' '2/^256=16 '?16 ^2 ' 256 Public Sub Main() Debug.Print Debug.Print "4/^256=4" Debug.Print "?"; Debug.Print Root(4, 256) & " ^ 4" Debug.Print Debug.Print "2/^823543=" & Sqr(823543) Debug.Print "?"; Debug.Print Root(2, 823543) & " ^2" Debug.Print Debug.Print "2/^56=" & Sqr(56) Debug.Print "?"; Debug.Print Root(2, 56) & " ^ 2" Debug.Print Debug.Print "2/^3283=" & Sqr(3283) Debug.Print "?"; Debug.Print Root(2, 3283) & " ^ 2" Debug.Print Debug.Print "2/^256=" & Sqr(256) Debug.Print "?"; Debug.Print Root(2, 256) & " ^2" Debug.Print End Sub Public Function Root(ByVal expo As Double, ByVal base As Double) As Double Dim cnt As Long Dim temp As Double Root = (base * (((base / expo) * ((base / expo) * (base / (expo * base))) / ((base \ expo) - (expo \ _ base))) / base)) * (expo / 50) * (((expo / base) * (base \ expo)) / ((base \ expo) ^ expo) / 100) cnt = -1 Do Do While Round(Root ^ expo, Len(Trim(Str(base - (Round(base, 0))))) - 1) < base Root = Root + CDbl("." & String(Len(Trim(Str(base - (Round(base, 0))))) + cnt, "0") & "1") Loop cnt = cnt + 1 Do While Round(Root ^ expo, Len(Trim(Str(base - (Round(base, 0))))) - 1) > base Root = Root - CDbl("." & String(Len(Trim(Str(base - (Round(base, 0))))) + cnt, "0") & "1") Loop If cnt > 10 Then cnt = -1 temp = Round(Root, Len(Trim(Str(base - (Round(base, 0))))) + cnt) Loop Until Round(temp ^ expo, 0) = Round(base, 0) And (((Len(Trim(Str((temp ^ expo) - (Round((temp ^ expo), 0)))))) > 10) _ Or (Len(Trim(Str((temp ^ expo) - (Round((temp ^ expo), 0))))) = Len(Trim(Str(base - (Round(base, 0))))))) Root = temp End Function```

Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

What do you think of this code (in the Intermediate category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)