Click to like/follow us on:
Write an algorithm that will request for an integer number, n and a real number x. The algorithm will calculate and display this function:
Premise:
In these example I will combine three different examples; Example Ten, Fourteen and Sixteen. There are the algorithms that compute the summation, power and factorial of any number.
Solution:
1.1 Request n
1.2 Request x
2.1 count = 1
2.3 power = 1.0
2.4 factorial = 1
2.5 evalue = 1 + (x)
2.6 IF n <> 0 && x <> 1 THEN
    2.6.1 count = count + 1
    2.6.2 power = power * (x)
    2.6.3 factorial = factorial * count
    2.6.4 Repeat 2.6.1, 2.6.2 and 2.6.3 until count <= n
    2.6.5 evalue = evalue + (power / factorial)
    ELSE
    2.6.6 Do nothing
3.1 Display evalue

Explanation:
And that is the algorithm that will calculate and display the function.
Line 2.6: IF n <> 0 && x <> 1. The operator less than and greater; "<>"; denotes "not equal to" in Qbasic programming language in java this will be used “!=” instead. The operator double ampersands; "&&"; is used to denoted "and" in java and in Qbasic it is use as "AND".
Therefore the statement; line 2.6; mean that if n is not zero and at SAME time x is not 1, then you should obey 2.6.1 - 2.6.5 Else if otherwise; 2.6.6 do nothing. Suppose n = 0 and x = 1. Then line 3.1 will display the value contain in 2.5; evalue = 1 + 1 = 2. Why because;
 And that is it!

SHARE THIS POST WITH YOUR FRIENDS...::

0 comments:

Leave a Reply

All Posts

Access all posts here!

Categories

Unordered List

Sample Text

Lists of Jobs in the United States

List of Courses & Outlines For UNN Students

Popular Posts

Like us on Facebook

Recent Posts

    Text Widget