mmavipc Posted November 29, 2008 Posted November 29, 2008 I know how to do this with a pencil and paper but how do I do it in autoit?http://en.wikipedia.org/wiki/Radical_of_an_integerfor example504 = 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
Ultima2 Posted November 29, 2008 Posted November 29, 2008 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)
oMBRa Posted November 29, 2008 Posted November 29, 2008 try this MsgBox(0, '', Radical(504)) Func Radical($Rad) Local $ToMul, $Splitted Local $Start = 1 If $Rad = 0 Then Return 0 EndIf For $x = 2 To 11 Do If Not IsFloat(Execute('$Rad / $x')) Then $Rad = Execute('$Rad / $x') If Not StringInStr($ToMul, $x) Then $ToMul = $ToMul & $x EndIf EndIf Until IsFloat(Execute('$Rad / $x')) Next $Splitted = StringSplit($ToMul, '') For $i = 1 To UBound($Splitted) - 1 $Start = Number($Start) * Number($Splitted[$i]) Next Return $Start EndFunc ;==>Radical
mmavipc Posted November 29, 2008 Author Posted November 29, 2008 try this MsgBox(0, '', Radical(504)) Func Radical($Rad) Local $ToMul, $Splitted Local $Start = 1 If $Rad = 0 Then Return 0 EndIf For $x = 2 To 11 Do If Not IsFloat(Execute('$Rad / $x')) Then $Rad = Execute('$Rad / $x') If Not StringInStr($ToMul, $x) Then $ToMul = $ToMul & $x EndIf EndIf Until IsFloat(Execute('$Rad / $x')) Next $Splitted = StringSplit($ToMul, '') For $i = 1 To UBound($Splitted) - 1 $Start = Number($Start) * Number($Splitted[$i]) Next Return $Start EndFunc ;==>Radicalthank you. With a few modifications to your code it now works great my code expandcollapse popupFunc R($Rad) if isprime($rad) Then return $rad EndIf Local $ToMul, $Splitted Local $Start = 1 If $Rad = 0 Then Return 0 EndIf For $x = 2 To 11 Do If Not IsFloat(Execute('$Rad / $x')) Then $Rad = Execute('$Rad / $x') If Not StringInStr($ToMul, $x) Then $ToMul = $ToMul & $x EndIf EndIf Until IsFloat(Execute('$Rad / $x')) Next $Splitted = StringSplit($ToMul, '') For $i = 1 To UBound($Splitted) - 1 $Start = Number($Start) * Number($Splitted[$i]) Next Return $Start EndFunc ;==>Radical 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
oMBRa Posted November 29, 2008 Posted November 29, 2008 this version should not has problem: MsgBox(0, '', Radical(7)) Func Radical($Rad) Local $ToMul, $Splitted Local $Start = 1 If $Rad = 0 Or 11 Or 13 Or 15 Or 17 Or 19 Then Return $Rad EndIf For $x = 2 To 19 Do If Not IsFloat(Execute('$Rad / $x')) Then $Rad = Execute('$Rad / $x') If Not StringInStr($ToMul, $x) Then $ToMul = $ToMul & $x EndIf EndIf Until IsFloat(Execute('$Rad / $x')) Next $Splitted = StringSplit($ToMul, '') For $i = 1 To UBound($Splitted) - 1 $Start = Number($Start) * Number($Splitted[$i]) Next Return $Start EndFunc ;==>Radical
mmavipc Posted November 29, 2008 Author Posted November 29, 2008 this version should not has problem: MsgBox(0, '', Radical(7)) Func Radical($Rad) Local $ToMul, $Splitted Local $Start = 1 If $Rad = 0 Or 11 Or 13 Or 15 Or 17 Or 19 Then Return $Rad EndIf For $x = 2 To 19 Do If Not IsFloat(Execute('$Rad / $x')) Then $Rad = Execute('$Rad / $x') If Not StringInStr($ToMul, $x) Then $ToMul = $ToMul & $x EndIf EndIf Until IsFloat(Execute('$Rad / $x')) Next $Splitted = StringSplit($ToMul, '') For $i = 1 To UBound($Splitted) - 1 $Start = Number($Start) * Number($Splitted[$i]) Next Return $Start EndFunc ;==>Radicaltry running this MsgBox(0, '', Radical(4)) Func Radical($Rad) Local $ToMul, $Splitted Local $Start = 1 If $Rad = 0 Or 11 Or 13 Or 15 Or 17 Or 19 Then Return $Rad EndIf For $x = 2 To 19 Do If Not IsFloat(Execute('$Rad / $x')) Then $Rad = Execute('$Rad / $x') If Not StringInStr($ToMul, $x) Then $ToMul = $ToMul & $x EndIf EndIf Until IsFloat(Execute('$Rad / $x')) Next $Splitted = StringSplit($ToMul, '') For $i = 1 To UBound($Splitted) - 1 $Start = Number($Start) * Number($Splitted[$i]) Next Return $Start EndFunc ;==>Radical 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
Mattraks Posted November 29, 2008 Posted November 29, 2008 Func Radical($Rad) Local $ToMul, $Splitted Local $Start = 1 If $Rad = 0 Or $Rad = 11 Or $Rad = 13 Or $Rad = 15 Or $Rad = 17 Or $Rad = 19 Then Return $Rad EndIf For $x = 2 To 19 Do If Not IsFloat(Execute('$Rad / $x')) Then $Rad = Execute('$Rad / $x') If Not StringInStr($ToMul, $x) Then $ToMul = $ToMul & $x EndIf EndIf Until IsFloat(Execute('$Rad / $x')) Next $Splitted = StringSplit($ToMul, '') For $i = 1 To UBound($Splitted) - 1 $Start = Number($Start) * Number($Splitted[$i]) Next Return $Start EndFunc
mmavipc Posted November 29, 2008 Author Posted November 29, 2008 Func Radical($Rad) Local $ToMul, $Splitted Local $Start = 1 If $Rad = 0 Or $Rad = 11 Or $Rad = 13 Or $Rad = 15 Or $Rad = 17 Or $Rad = 19 Then Return $Rad EndIf For $x = 2 To 19 Do If Not IsFloat(Execute('$Rad / $x')) Then $Rad = Execute('$Rad / $x') If Not StringInStr($ToMul, $x) Then $ToMul = $ToMul & $x EndIf EndIf Until IsFloat(Execute('$Rad / $x')) Next $Splitted = StringSplit($ToMul, '') For $i = 1 To UBound($Splitted) - 1 $Start = Number($Start) * Number($Splitted[$i]) Next Return $Start EndFuncyour code doesn't work either 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
BugFix Posted November 29, 2008 Posted November 29, 2008 (edited) Hi,here my solution to get radical:Note: The algorithm based by Klaus Merkert, Hohenstaufen-Gymnasium Kaiserslautern, http://www.hsg-kl.deexpandcollapse popupFunc _Radical($n) Local $F = ObjCreate("System.Collections.ArrayList") While Mod($n,2) == 0 If Not $F.Contains(2) Then $F.add(2) $n = $n/2 WEnd While Mod($n,3) == 0 If Not $F.Contains(3) Then $F.add(3) $n = $n/3 WEnd Local $t = 5 Local $diff = 2 While $t*$t <= $n While Mod($n,$t) == 0 If Not $F.Contains($t) Then $F.add($t) $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 $F.add(2) $n = $n/2 WEnd While Mod($n,3) == 0 $F.add(3) $n = $n/3 WEnd Local $t = 5 Local $diff = 2 While $t*$t <= $n While Mod($n,$t) == 0 $F.add($t) $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 November 30, 2008 by BugFix Best Regards BugFix
mmavipc Posted November 30, 2008 Author Posted November 30, 2008 Hi, here my solution to get radicand: Func _Radical($n) Local $F = ObjCreate("System.Collections.ArrayList") While Mod($n,2) == 0 If Not $F.Contains(2) Then $F.add(2) $n = $n/2 WEnd While Mod($n,3) == 0 If Not $F.Contains(3) Then $F.add(3) $n = $n/3 WEnd Local $t = 5 Local $diff = 2 While $t*$t <= $n While Mod($n,$t) == 0 If Not $F.Contains($t) Then $F.add($t) $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 EndFuncoÝ÷ Ø Ýû(ê'zwu¬ÊÚ zÚkgiËh®Êjx§µè«¢+ÙÕ¹}ÑAÉ¥µÑ½ÉÌ ÀÌØí¸¤(1½°ÀÌØíô=© ÉÑ ÅÕ½Ðí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
danyel Posted January 4, 2016 Posted January 4, 2016 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
danyel Posted January 4, 2016 Posted January 4, 2016 bdw cant make imagesearch work in windows 10 ... any solution for that ??
Moderators Melba23 Posted January 4, 2016 Moderators Posted January 4, 2016 (edited) danyel,Welcome to the AutoIt forums.But in future please do not reply to 7 year old threads....M23P.S. And certainly do not hijack them - start your own thread. Edited January 4, 2016 by Melba23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area
Recommended Posts