done
![Smile :)](./images/smilies/icon_e_smile.gif)
Pretty scary stuffSum of first N natural numbers, sum of their squares/cubes....till power 10
Code: Select all
;Base to Number and Number to Base conversion
;Base = 16 for HexaDecimal , 2 for Binary, 8 for Octal and 10 for our own number system
number := 10241212
msgbox % t := Number2Base(number, 16)
msgbox % Base2Number(t, 16)
Number2Base(N, base=16){
loop % baseLen:=base<10?Ceil((10/base)*Strlen(N)):Strlen(N)
D:=Floor(N/(T:=base**(baseLen-A_index))),H.=!D?0:(D>9?Chr(D+87):D),N:=N-D*T
return Ltrim(H,"0")
}
Base2Number(H, base=16){
S:=Strlen(H),N:=0
loop,parse,H
N+=((A_LoopField*1="")?Asc(A_LoopField)-87:A_LoopField)*base**(S-A_index)
return N
}
That might have required some great thinking. :Hats Off:smorgasbord wrote:rest i guess is redundant.
OK , then I will start a new topic hosting the code, OR you can simply link it in the OP. This topic deserves to be in Scripts and Functions, if you too feel so please contact a moderator.smorgasbord wrote:but i doubt the guys who reach till here will be few and far in between (at my pace)
Good work and I feel it should work till infinity. ( much like SM_Fact() )smorgasbord wrote:Extremely large factorial calculator added, dont know the limit how large, if time permits will make the current limit increased further to that limit raised to the same limit.
Code: Select all
Clipboard := "" final
Code: Select all
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn ; Enable warnings to assist with detecting common errors.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
FileDelete, result.txt
InputBox, k, Any degree polynomial solver, Enter (Inegral) `coefficients of X in decreading orders of (Integral) power of X with + or - sign as the case may be`n`nThe last coefficient shall be the coefficient of x raised to power 0`n`nFor Eg.`nIF Equation: 5X^2+1=0 and the limit you want is -10 to 10`nEnter +5+0+1COMMA10`nPut this script in a separate folder`nExtract nearest roots from first few lines of sort.txt file`n`n`under testing., , 640, 640
StringSplit, m, k, `,
check := 0-m2
limit := 2 * abs(check)
result := 0
k := m1
NUMBERS := RegExReplace(k, "-", "+")
StringSplit, N, numbers, +
SIGNS := RegExReplace(k, "\d+", "|")
StringSplit, S, SIGNS, |
Loop % 2 * (s0-1)
{
omg := mod(A_index, 2)
if ( omg == 0 ) ; even
{
index := floor(A_index/2) + 1
k%A_index% := n%index%
index =
}
else ; odd
{
index := floor( (A_index + 1) / 2 )
k%A_index% := s%index%
index =
}
}
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Power := s0 - 1
;MsgBox power is %power%
Loop
{
if ( check > m2 + 1 )
break
Loop, % power
{
o1 := 2 * A_index - 1 ; 1,3,5,7,9..signs
e := 2 * A_index ; 2,4,6,8, coefficients
;MsgBox %check% is check
o1 := k%o1%
; MsgBox %o1% must be +
if ( o1 = "+" )
{
result := result + k%e% * ( check ** (Power-1) )
;MsgBox %result% for +
if ( abs(check) = 0 )
result := 0 + k%n0%
}
else
{
result := result - k%e% * ( check ** (Power-1) )
;MsgBox %result% for -
if ( abs(check) = 0 )
result := 0 - k%n0%
}
; MsgBox % result "power is" power - 1
power --
}
;MsgBox %result% for check %check%
;MsgBox % result " again"
absolute := abs(result)
FileAppend, %absolute% is absolute value for comparison & result is %result% for x %check% `n, result.txt
;Power := floor(k0/2)
Power := s0 - 1
result := 0
check := check + 0.1
}
FileRead, Contents, result.txt
if not ErrorLevel ; Successfully loaded.
{
Sort, Contents
FileDelete, sort.txt
FileAppend, %Contents%, sort.txt
Contents = ; Free the memory.
}
;MsgBox check Sort file in the folder of the script is located
loop, % power - 1
{
filereadline, ans_, sort.txt, A_index
StringSplit, ans, ans_, %A_space%
;MsgBox % ans0
if ( abs(ans1) = 0 )
final .= ans1 " for x " ans13 . ans14 . " Real Root" . "`n"
else
final .= ans1 " for x " ans13 . ans14 . " Not exact AND/OR non-real root" . "`n"
}
MsgBox %final% `nThe script so far cannot evaluate imaginery roots `n`nAnd as such they need to be ruled out on your own.
ExitApp
esc::exitapp
smorgasbord wrote:the scripts splitsthe string based on + OR - sign and the checks for all values from - limiter to + limiter that user enters after comma, The increment is 0.1 which can be changed ( line 82) may be
and returns the nearest values
Return to “Other Utilities & Resources”
Users browsing this forum: No registered users and 9 guests