Week 6 Tasks

Looping

$ for $ loop

Task 26

WAP to find if the entered number is a prime number or not.

Hint:
A prime number is a natural number greater than 1 that cannot be formed by multiplying two smaller natural numbers.

Task 27 (Experiment 10)

WAP to find the sum and average of the numbers entered by the user.

Task 28 (Experiment 11)

WAP to print Fibonacci Series till number entered by the user is reached.

Fibonacci Series is a sequence of numbers in which each number is the sum of the two preceding ones, starting from 0 and 1.

0, 1, 1, 2, 3, 5, 8, 13, 21, 34, ...

Task 29 (Experiment 12)

WAP to print the following pattern.

List of Patterns

Task 30 (Bonus Task)

WAP to the following series where user enters the value for $n$. Also compute the value of the series.

$$ 1 + \frac{1}{2} + \frac{1}{4} + \frac{1}{8} + ... + \frac{1}{2^n} $$