Professional Documents
Culture Documents
Exercise 1
Find the N Fibonacci number
Algorithm
•Step 1 : Input N
•Step 2 : Assign i 2, Fn-1 1, Fn-2 1, Fn 1
•Step 3 : If i < N goto Step 4.
Else output Fn. End.
•Step 4 : Assign Fn Fn-1 + Fn-2
Assign Fn-2 Fn-1
Assign Fn-1 Fn
Assign i i + 1
Goto Step 3
2
Excercise 1 request:
• Draw a flowchart
• Run the algorithm with N=6 and draw a table of all the
variables
i
Fn-2
Fn-1
Fn
3
Exercise 2: Make an algorithm in psudocode and flowchart
4
Exercise 3
• Find the greatest common divisor (GCD) and the least common factor (LCF)
of two variables a and b
5
Exercise 4
Find all divisors of a positive integer N
6
Exercise 5
1. Find all odd disivors of a positive integer N
• Idea: Check all values from 1 to N and print out values that are divisors of
N.
7
Exercise 6
Create an algorithm (by flowchart and psudocode) that:
Show all perfect number from the range [1,10000]