Jump to content
Sign in to follow this  
cppman

Summation Solver

Recommended Posts

cppman

I have been having to do summations(by hand) for homework and it is a pain in the ass. I decided to write this function to help me out with solving them. Maybe someone else might find it as useful as I did/do.

Func Summation($nEndCount, $szStartExpression, $szResultOpe][Û ÌÍÛ]HHJBNÈHH][Ý[NÈH]Ý[ÈW&W6VçFærFFFöâ÷W&Föç0 ´4õTåBDòÂ5D%DärôåBÂõU$Dôà ³#ðàôÐðáx Դ̤($ÀÌØíÍéÅÕÑ¥½¸ôMÑÉ¥¹MÑÉ¥Á]L ÀÌØí¹ndCount & "|" & $szStartExpression & "|&quoÈ [È ÌÍÜÞÝ[Ü][Û
BIÌÍÜÞ[ÈHÝ[ÔÜ]
    ÌÍÜÞVFöâÂgV÷C·ÂgV÷C² b33c·7¥f'2Ò7G&æu7ÆBb33c·7¥&×5³%ÒÂgV÷ìôÅÕ½Ðì¤($ÀÌØíÍéYÉ¥±9µôÀÌØíÍéYÉÍlÅt($ÀÌØí¹YÉ¥±Y±Õô%t($szVars[2])
    $szResultString = ""
    For $i = &#03ÛXXU[YHÈ^XÝ]J   ÌÍÜÞ[ÖÌWJBBIÌÍÜÞÝ[Ý[È  [ÏgV÷C²²gV÷C²fײ7G&æu&WÆ6Rb33c·7¥&W7VÇD÷W&FöâÂb33c·7¥f&&9µ°ÀÌØí¤¤µÀìÅÕ½Ðì¤ÅÕ½Ðì(%9áÐ($ÀÌØíÍéIÍÕ±ÑMÑÉ¥¹ôMÑÉ¥¹IÁace(StringTrimLeft($szResultString, 1), "+", " + "BZY
    ÌÍÛ]HOHJH[B]
^XÝ]J  ÌÍÜÞÝ[Ý[ÊJBQÇ6Vbb33c¶å&WEGRÓÒFVà &WGW&âb33c·7¥&W7VÇE7G&ær VÇ6P &WÕɸ¡áÕÑ ÀÌØíÍéIÍÕ±ÑMÑÉ¥¹¤¤(%¹%)¹Õ¹(oÝ÷ Ù:.±è­Ê£ºËgyçm¢Ê^r'òÞØbÚ)¶*'jYrá8^~*춫jg­z¸´ß©ÄШº{+-éî·«Ê°¢é]±çnÞ¶¬ ²('¶ërÝ¥ªÚë^®-7êÌÒµªíkzË"¢âËayìi­ë,í¢ËZ®Ûaz˦«b¢r-ë-ríj)Ú½ªâi¹^©z
ýZØZ½æ§z«È ­«Ú碷±jjez«¨¶

which would result in either:

((0^2) + (6*0)) + ((1^2) + (6*1)) + ((2^2) + (6*2)) + ((3^2) + (6*3)) + ((4^2) + (6*4)) + ((5^2) + (6*5)) + ((6^2) + (6*6)) + ((7^2) + (6*7)) + ((8^2) + (6*8)) + ((9^2) + (6*9)) + ((10^2) + (6*10)) + ((11^2) + (6*11)) + ((12^2) + (6*12))

or

1118

Setting the $nType will change the way it is returned. If you set it to 0 it will return that very long equation. If it is set to 1 it will solve that problem and return the result.

Maybe you might find it useful.. enjoy.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×