Science Forums

# How Do You Write A Algorithm?

## Recommended Posts

So, I know algorithms are very complicated and such, but if you would take the time, can you please give me a step by step way to make an algorithm for this problem. I'm not sure which version you need, an algebraic one or one with numbers so I'll put both.

(a(3+a)(bc - jk)za

(1(1+3)(2*3) - (10*11)) (26*1)

<p>

=) Thanks for anyone who takes the time!

~Clover

##### Share on other sites

an algorithm is simply a series of steps to achieve a particular goal.

(1(1+3)((2*3) - (10*11)) (26*1)

add 1 and 3, multiply 2 and 3, multiply 10 and 11, multiply 26 and 1.

(1*4*(6 - 110))*26

subtract 110 from 6.

1*4*-104*26

multiply 1, 4, -104 and 26.

-10816

##### Share on other sites

if you mean a computer algorithm, then...

a = 1

b = 2

c = 3

j = 10

k = 11

z = 26

print (a*(3+a)*((b*c) -(j*k)))*z*a

would be an example.

##### Share on other sites

• 4 months later...

So, I know algorithms are very complicated and such, but if you would take the time, can you please give me a step by step way to make an algorithm for this problem. I'm not sure which version you need, an algebraic one or one with numbers so I'll put both.

(a(3+a)(bc - jk)za

(1(1+3)(2*3) - (10*11)) (26*1)

Clover,

An algorithm for above example as philip1882 showed you is trivial. So an

algorithm may need a better example.

Say you have twelve suits on a rack and you want to know how many you

have that are double breasted with matching pants.

Showing you this algorithm [in pseudocode] is thus

get coat rack

for each hanger in rack

- if contents of hanger is suit then

-- if contents of hanger has pants

--- if contents of hanger that is suit of type "double breasted" then

--- if contents of hanger that is suit "match" contents of hanger that is pants then

---- incr count by 1

print count

Now this is Not code of any language. One could though by defining a

few things write an actual program in any language.

Only increment our counter if what is found on each hanger is a suit,

that is double breasted and that has pants that match.

Another example is a fractal. Fractals such as the Mandlebrot set

are iteration functions that are mapped on the whole complex pane.

In case you do not know of complex arithmetic a brief intro

A complex number is Z = ax + iby where a, b are some constants, x, y

are your coordinates in a plane and i = sqrt(-1).

So an iteration function is for example Z = Z^2 + c where c is some

complex constant say (a, b ) or c = a + ib.

You then plot this for the whole complex plane. You get a Mandlebrot set.

I will leave this as an exercise for you to work out an algorithm in

pseudocode.

##### Share on other sites

• 2 months later...

Thanks friends for discussing such nice algorithms,please discuss some more maths related algorithm as maths involves in every field of science,would you like to discuss probability worksheet or probability related problems.

Edited by suresh kumawat
##### Share on other sites

An algorhythm is a generic "method" one will use to design the code for a task. It would be advisable, though, to knoiw your chosen compiler first, prior to even pseudocode, because C/C++ is very different than say Pascal or Basic.

I just put this link for another query, but you can find a lot of Basic compilers here. I think I placed a link there once to Delphi 7 PE, but Borland no longer supports it largely because Borlsnd is no more.

I'm saying this because D7 has so many math routines that any Delphi version makes life easy for math guys.

EBasic or IWBasic have floor and ceil routines that allow for integration routines, summation. So does Delphi. Delphi has string variables and converters and allow extremely long floats. An algebraist's dream

## Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

Only 75 emoji are allowed.

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.