Vous êtes sur la page 1sur 3

SMBE2033 COMPUTER PROGRAMMING FOR BIOMEDICAL

ENGINEERS

ASSIGNMENT 1 – ALGORITHM AND FLOWCHART

DONE BY: AAISHA NEGEH BAH A17MB0216

DATE OF SUBMISSION: TUESDAY, SEPTEMBER 25, 2018


1. Complete the table below using the example shown above to prove that you really
understand the algorithm. The first few rows have shown you some example to fill-up
the columns (the steps referring to the line number in the algorithm).

U = x*y mod M = 19*4 mod 23


x = 19, y = 4, M = 23

Step A U V P
1 4 0 19 23
2, 5 2
6 38
7 15
1 2 0 15 23
2, 5 1
6 30
7 7
1 1 0 7 23
2,5 7
6 14
7
8 7

Your answer that return by U should be 7, which is same with manual calculation.

2. After you have proven your understanding of the modular multiplication algorithm, draw
the flowchart according to the algorithm.
Start

Input x=19, y-4, M=23 : y ,x ε [1, M-1]


Output U = (x*y) mod M

Initialize U=0, V=x, A=y, P=M

Yes
A=0?

No

No 𝐴0 =1?
U

Yes
End
U=U+V

No
U≥P?

Yes

U=U-P

A=A/2
V=2V

No
V≥P?

Yes
V=V-P

Vous aimerez peut-être aussi