# Geting the Radical of a number?

## Recommended Posts

I know how to do this with a pencil and paper but how do I do it in autoit?

for example

504 = 2^3 * 3^2 * 7

and Rad(504) = 2 * 3 * 7 = 42

[size="10"]Pure Au3 crypt funcs(I'm currently also working on making a dll from this)[/size][Y] Be more active in the community[Y] Get 200 posts[N] Get 300 posts[N] Make a Topic in the example scripts forum with at least 50 replies.People who currently hate me:ValikSmOke_N

##### Share on other sites

You could try raising it to a fractional power.

9^(1/2) = 3

Which is the same as rad 9

a code could be

\$i = 9^(1/2)

##### Share on other sites

try this

```MsgBox(0, '', Radical(504))

Local \$ToMul, \$Splitted
Local \$Start = 1
Return 0
EndIf

For \$x = 2 To 11
Do
If Not IsFloat(Execute('\$Rad / \$x')) Then
If Not StringInStr(\$ToMul, \$x) Then
\$ToMul = \$ToMul & \$x
EndIf
EndIf
Next
\$Splitted = StringSplit(\$ToMul, '')

For \$i = 1 To UBound(\$Splitted) - 1
\$Start = Number(\$Start) * Number(\$Splitted[\$i])
Next
Return \$Start

##### Share on other sites

try this

```MsgBox(0, '', Radical(504))

Local \$ToMul, \$Splitted
Local \$Start = 1
Return 0
EndIf

For \$x = 2 To 11
Do
If Not IsFloat(Execute('\$Rad / \$x')) Then
If Not StringInStr(\$ToMul, \$x) Then
\$ToMul = \$ToMul & \$x
EndIf
EndIf
Next
\$Splitted = StringSplit(\$ToMul, '')

For \$i = 1 To UBound(\$Splitted) - 1
\$Start = Number(\$Start) * Number(\$Splitted[\$i])
Next
Return \$Start
thank you. With a few modifications to your code it now works great

my code

```Func R(\$Rad)
EndIf
Local \$ToMul, \$Splitted
Local \$Start = 1
Return 0
EndIf

For \$x = 2 To 11
Do
If Not IsFloat(Execute('\$Rad / \$x')) Then
If Not StringInStr(\$ToMul, \$x) Then
\$ToMul = \$ToMul & \$x
EndIf
EndIf
Next
\$Splitted = StringSplit(\$ToMul, '')

For \$i = 1 To UBound(\$Splitted) - 1
\$Start = Number(\$Start) * Number(\$Splitted[\$i])
Next
Return \$Start
func isprime(\$int)
dim \$np = True
for \$i = 2 to 9
\$d = \$int / \$i
if \$i <> \$int and IsInt(\$d) Then
\$np = False
ExitLoop
EndIf
Next
return \$np
EndFunc```

[size="10"]Pure Au3 crypt funcs(I'm currently also working on making a dll from this)[/size][Y] Be more active in the community[Y] Get 200 posts[N] Get 300 posts[N] Make a Topic in the example scripts forum with at least 50 replies.People who currently hate me:ValikSmOke_N

##### Share on other sites

this version should not has problem:

```MsgBox(0, '', Radical(7))

Local \$ToMul, \$Splitted
Local \$Start = 1
If \$Rad = 0 Or 11 Or 13 Or 15 Or 17 Or 19 Then
EndIf

For \$x = 2 To 19
Do
If Not IsFloat(Execute('\$Rad / \$x')) Then
If Not StringInStr(\$ToMul, \$x) Then
\$ToMul = \$ToMul & \$x
EndIf
EndIf
Next
\$Splitted = StringSplit(\$ToMul, '')

For \$i = 1 To UBound(\$Splitted) - 1
\$Start = Number(\$Start) * Number(\$Splitted[\$i])
Next
Return \$Start

##### Share on other sites

this version should not has problem:

```MsgBox(0, '', Radical(7))

Local \$ToMul, \$Splitted
Local \$Start = 1
If \$Rad = 0 Or 11 Or 13 Or 15 Or 17 Or 19 Then
EndIf

For \$x = 2 To 19
Do
If Not IsFloat(Execute('\$Rad / \$x')) Then
If Not StringInStr(\$ToMul, \$x) Then
\$ToMul = \$ToMul & \$x
EndIf
EndIf
Next
\$Splitted = StringSplit(\$ToMul, '')

For \$i = 1 To UBound(\$Splitted) - 1
\$Start = Number(\$Start) * Number(\$Splitted[\$i])
Next
Return \$Start
try running this

```MsgBox(0, '', Radical(4))

Local \$ToMul, \$Splitted
Local \$Start = 1
If \$Rad = 0 Or 11 Or 13 Or 15 Or 17 Or 19 Then
EndIf

For \$x = 2 To 19
Do
If Not IsFloat(Execute('\$Rad / \$x')) Then
If Not StringInStr(\$ToMul, \$x) Then
\$ToMul = \$ToMul & \$x
EndIf
EndIf
Next
\$Splitted = StringSplit(\$ToMul, '')

For \$i = 1 To UBound(\$Splitted) - 1
\$Start = Number(\$Start) * Number(\$Splitted[\$i])
Next
Return \$Start
i get 4 i shoudl get 2

and running my previous code for getting the radical of 39 instead of getting 39(3*13) as expected i get 3

[size="10"]Pure Au3 crypt funcs(I'm currently also working on making a dll from this)[/size][Y] Be more active in the community[Y] Get 200 posts[N] Get 300 posts[N] Make a Topic in the example scripts forum with at least 50 replies.People who currently hate me:ValikSmOke_N

##### Share on other sites

```Func Radical(\$Rad)
Local \$ToMul, \$Splitted
Local \$Start = 1
EndIf

For \$x = 2 To 19
Do
If Not IsFloat(Execute('\$Rad / \$x')) Then
If Not StringInStr(\$ToMul, \$x) Then
\$ToMul = \$ToMul & \$x
EndIf
EndIf
Next
\$Splitted = StringSplit(\$ToMul, '')

For \$i = 1 To UBound(\$Splitted) - 1
\$Start = Number(\$Start) * Number(\$Splitted[\$i])
Next
Return \$Start
EndFunc```

##### Share on other sites

```Func Radical(\$Rad)
Local \$ToMul, \$Splitted
Local \$Start = 1
EndIf

For \$x = 2 To 19
Do
If Not IsFloat(Execute('\$Rad / \$x')) Then
If Not StringInStr(\$ToMul, \$x) Then
\$ToMul = \$ToMul & \$x
EndIf
EndIf
Next
\$Splitted = StringSplit(\$ToMul, '')

For \$i = 1 To UBound(\$Splitted) - 1
\$Start = Number(\$Start) * Number(\$Splitted[\$i])
Next
Return \$Start
EndFunc```

try MsgBox(0, '', radical(39)) expected 39(13*3) got 9

[size="10"]Pure Au3 crypt funcs(I'm currently also working on making a dll from this)[/size][Y] Be more active in the community[Y] Get 200 posts[N] Get 300 posts[N] Make a Topic in the example scripts forum with at least 50 replies.People who currently hate me:ValikSmOke_N

##### Share on other sites

Hi,

here my solution to get radical:

Note: The algorithm based by Klaus Merkert, Hohenstaufen-Gymnasium Kaiserslautern, http://www.hsg-kl.de

```Func _Radical(\$n)
Local \$F = ObjCreate("System.Collections.ArrayList")
While Mod(\$n,2) == 0
\$n = \$n/2
WEnd
While Mod(\$n,3) == 0
\$n = \$n/3
WEnd
Local \$t = 5
Local \$diff = 2
While \$t*\$t <= \$n
While Mod(\$n,\$t) == 0
\$n = \$n/\$t
WEnd
\$t = \$t + \$diff
\$diff = 6 - \$diff
WEnd
If \$n > 1 And Not \$F.Contains(\$n) Then \$F.add(\$n)
Local \$out = 1
For \$element In \$F
\$out *= \$element
Next
Return \$out
EndFunc

; If someone need: a function to get prime factors
Func _GetPrimeFactors(\$n)
Local \$F = ObjCreate("System.Collections.ArrayList")
While Mod(\$n,2) == 0
\$n = \$n/2
WEnd
While Mod(\$n,3) == 0
\$n = \$n/3
WEnd
Local \$t = 5
Local \$diff = 2
While \$t*\$t <= \$n
While Mod(\$n,\$t) == 0
\$n = \$n/\$t
WEnd
\$t = \$t + \$diff
\$diff = 6 - \$diff
WEnd
If \$n > 1 Then \$F.add(\$n)
Local \$out = ''
For \$element In \$F
\$out &= \$element & ','
Next
Return StringTrimRight(\$out, 1)
EndFunc```
Edited by BugFix

Best Regards BugFix

##### Share on other sites

Hi,

here my solution to get radicand:

```Func _Radical(\$n)
Local \$F = ObjCreate("System.Collections.ArrayList")
While Mod(\$n,2) == 0
\$n = \$n/2
WEnd
While Mod(\$n,3) == 0
\$n = \$n/3
WEnd
Local \$t = 5
Local \$diff = 2
While \$t*\$t <= \$n
While Mod(\$n,\$t) == 0
\$n = \$n/\$t
WEnd
\$t = \$t + \$diff
\$diff = 6 - \$diff
WEnd
If \$n > 1 And Not \$F.Contains(\$n) Then \$F.add(\$n)
Local \$out = 1
For \$element In \$F
\$out *= \$element
Next
Return \$out
ÉÑ ÅÕ½ÐíMåÍÑ´¹
½±±Ñ¥½¹Ì¹ÉÉå1¥ÍÐÅÕ½Ðì¤(]¡¥±5½ ÀÌØí¸°È¤ôôÀ(ÀÌØí¹ È¤(ÀÌØí¸ôÀÌØí¸¼È(%]¹(]¡¥±5½ ÀÌØí¸°Ì¤ôôÀ(ÀÌØí¹ Ì¤(ÀÌØí¸ôÀÌØí¸¼Ì(%]¹(1½°ÀÌØíÐôÔ(1½°ÀÌØí¥ôÈ(]¡¥±ÀÌØíÐ¨ÀÌØíÐ±ÐìôÀÌØí¸(]¡¥±5½ ÀÌØí¸°ÀÌØíÐ¤ôôÀ(ÀÌØí¹ ÀÌØíÐ¤(ÀÌØí¸ôÀÌØí¸¼ÀÌØíÐ(\$%]¹(ÀÌØíÐôÀÌØíÐ¬ÀÌØí¥(ÀÌØí¥ôØ´ÀÌØí¥(%]¹(%ÀÌØí¸ÐìÄQ¡¸ÀÌØí¹ ÀÌØí¸¤(%1½°ÀÌØí½ÕÐôÌäìÌäì(%½ÈÀÌØí±µ¹Ð%¸ÀÌØí(\$\$ÀÌØí½ÕÐµÀìôÀÌØí±µ¹ÐµÀìÌäì°Ìäì(%9áÐ(%IÑÕÉ¸MÑÉ¥¹QÉ¥µI¥¡Ð ÀÌØí½ÕÐ°Ä¤)¹Õ¹```
THANK YOU

[size="10"]Pure Au3 crypt funcs(I'm currently also working on making a dll from this)[/size][Y] Be more active in the community[Y] Get 200 posts[N] Get 300 posts[N] Make a Topic in the example scripts forum with at least 50 replies.People who currently hate me:ValikSmOke_N

##### Share on other sites

just use this :

\$r=1/2 ; where 2 is ur radical power

27^\$r ; that is all .....

________

\$variable^\$variable2

where \$variable is ur number

\$variable2 is 1/ur_power

##### Share on other sites

bdw cant make imagesearch work in windows 10 ... any solution for that ??

##### Share on other sites

danyel,

Welcome to the AutoIt forums.

M23

P.S. And certainly do not hijack them - start your own thread.

Edited by Melba23

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

##### Share on other sites
This topic is now closed to further replies.

×

• Wiki

• Back

• Git