Question Set 5

“Simplicity is prerequisite for reliability.” — Edsger Dijkstra

Problem 1-Fibonacci Series (Easy)

The Fibonacci sequence is a series where the next term is the sum of previous two terms. The first two terms of the Fibonacci sequence is 0 followed by 1.Print Fibonacci Series upto a number n.

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


Problem 2-Factorial (Easy)

Factorial of a non-negative integer, is multiplication of all integers smaller than or equal to n. For example factorial of 6 is 6*5*4*3*2*1 which is 720.
Find factorial of a number N.


Problem 3-Primality Test (Easy)

Given a positive integer, check if the number is prime or not. A prime is a natural number greater than 1 that has no positive divisors other than 1 and itself.Examples of first few prime numbers are 2, 3, 5, 7, 11 .....


Problem 4-Primality Test using Seive (Medium)

Given a number n, print all primes smaller than or equal to n. It is also given that n is a small number.

Input : n =10
Output : 2 3 5 7


Comments

Popular posts from this blog

Question Set 4

Question Set 2