Page 73 - Digicode_AI_class_6
P. 73

Example 4: Write an algorithm and draw a flowchart to calculate the factorial of a number.

                            Algorithm:                                Flowchart:

             Step 1   Start.
                                                                         Start
             Step 2   Read the number n.
                                                                        Read n
             Step 3   Let i=1, fact=1

             Step 4    Check If i < = n Then Repeat Step
                                                                     i = 1, fact = 1
                     5 and 6 until i=n

             Step 5   fact=fact*i                                          Is
                                                                                     No
                                                                          i < =
             Step 6   i=i+1
                                                                           n?
             Step 7   Print fact                                             Yes

             Step 8   End.                                           fact = fact*i
                                                                                                Print fact

                                                                        i = i + 1


                                                                          Stop





                                                                                 Critical Thinking
                   code Quest                                                    Information Literacy



                 Write an algorithm to calculate the area of a triangle.
















            Mind Map

            A  Mind  Map  is  also  a  problem-solving  technique  that  allows  us  to  organise  ideas,  thoughts  or
            concepts and their relationship in a graphical manner.
            In this technique, we pick up the ideas that have common features. These ideas are then grouped
            under  one  category,  and  the  different  categories  are  linked  to  the  main  topic  using  lines  or
            arrows.






                                                                                 Algorithmic Intelligence  71
   68   69   70   71   72   73   74   75   76   77   78