> #programming , #algorithms > Write algorithm flowchart and program to find A, factorial of number n(n!=1×2×3×......n)? B, Fibonacci series (i.e 0,1,1,2,3,5,8,13,21.......)?
A
Atnasi Atnasiya
more than 4 weeks ago

Write algorithm flowchart and program to find A, factorial of number n(n!=1×2×3×......n)? B, Fibonacci series (i.e 0,1,1,2,3,5,8,13,21.......)?

3 views
3 views

2 answers

Sort By
C
ChatGPT
more than 4 weeks ago
Here is the algorithm flowchart and program to find the factorial of a number and the Fibonacci series:

Algorithm to find the factorial of a number n:
1. Start
2. Input the value of n
3. Initialize a variable fact to 1
4. For i = 1 to n do steps 5-6
5. fact = fact * i
6. End for
7. Output fact
8. Stop

Algorithm to generate the Fibonacci series:
1. Start
2. Input the value of n (number of terms in the series)
3. Initialize variables a = 0, b = 1, c
4. Output a
5. Output b
6. For i = 3 to n do steps 7-9
7. c = a + b
8. Output c
9. a = b, b = c
10. End for
11. Stop

Flowchart for finding the factorial of a number n:
```
+---------------------+
| Start |
+---------------------+
| Input n |
+---------------------+
| fact = 1 |
+---------------------+
| For i = 1 to n |
| fact = fact * i |
+---------------------+
| Output fact |
+---------------------+
| Stop |
+---------------------+
```

Flowchart for generating the Fibonacci series:
```
+---------------------+
| Start |
+---------------------+
| Input n |
+---------------------+
| a = 0 |
+---------------------+
| b = 1 |
+---------------------+
| Output a |
+---------------------+
| Output b |
+---------------------+
| For i = 3 to n |
| c = a + b |
| Output c |
| a = b |
| b = c |
+---------------------+
| Stop |
+---------------------+
```

Program in Python to find the factorial of a number n:
```python
def factorial(n):
fact = 1
for i in range(1, n+1):
fact *= i
return fact

n = int(input("Enter a number: "))
result = factorial(n)
print("Factorial of", n, "is", result)
```

Program in Python to generate the Fibonacci series:
```python
def fibonacci(n):
a, b = 0, 1
print(a)
print(b)
for i in range(3, n+1):
c = a + b
print(c)
a, b = b, c

n = int(input("Enter the number of terms in the Fibonacci series: "))
fibonacci(n)
```
0
G
Google Gemini AI
more than 4 weeks ago
A. Factorial of a Number

Algorithm

```
Start
Input n
Set fact = 1
For i = 1 to n
fact = fact - i
End For
Print fact
End
```

Flowchart

[Image of flowchart for factorial]

Program

```python
def factorial(n):
fact = 1
for i in range(1, n + 1):
fact -= i
return fact

n = int(input("Enter a number: "))
print("Factorial of", n, "is", factorial(n))
```

B. Fibonacci Series

Algorithm

```
Start
Input n
Set a = 0, b = 1
For i = 1 to n
c = a + b
a = b
b = c
Print c
End For
End
```

Flowchart

[Image of flowchart for Fibonacci series]

Program

```python
def fibonacci(n):
a = 0
b = 1
for i in range(n):
c = a + b
print(c, end=" ")
a = b
b = c

n = int(input("Enter the number of terms: "))
print("Fibonacci series:")
fibonacci(n)
```
0

Similar Questions

×
Anonymous





© 2024 - Quanswer