0% found this document useful (0 votes)
3 views

Algorithm and Flowchart for G

Uploaded by

asadsattarmian2
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

Algorithm and Flowchart for G

Uploaded by

asadsattarmian2
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

Algorithm and Flowchart for G.C.D.

(Greatest Common Divisor)

Algorithm:

1. Start.
2. Input two numbers, A and B.
3. While B is not equal to 0, repeat the following steps:
o Set Temp = B.
o Set B = A mod B.
o Set A = Temp.
4. Output A as the G.C.D.
5. End.

Algorithm and Flowchart for Factorial of a Number

Algorithm:

1. Start.
2. Input a number, N.
3. Initialize Fact = 1.
4. For i from 1 to N, do:
o Fact = Fact × i.
5. Output Fact as the factorial.
6. End.

Algorithm and Flowchart for Fibonacci Series

Algorithm:

1. Start.
2. Input the number of terms, N.
3. Initialize a = 0, b = 1, and i = 1.
4. While i ≤ N, repeat the following steps:
o Output a.
o Set Temp = a + b.
o Set a = b.
o Set b = Temp.
o Increment i by 1.
5. End.

Algoritm and Flowchart for Prime Numbers Between Two Numbers


Algorithm:

1. Start.
2. Input two numbers, StartNum and EndNum.
3. For each number, Num, from StartNum to EndNum:
o Set IsPrime = true.
o For each i from 2 to √Num:
 If Num mod i = 0, set IsPrime = false and break.
o If IsPrime is true and Num > 1, output Num.
4. End.

You might also like