(1869 Views)

Prime numbers are one of the most basic concept of mathematics and are studied in a theory called number theory.

Primes are the numbers that can only be divided by 1 and and the number itself. For example, 11 is a prime number since I'm left with a remainder if I divide 11 by any number other than 11 or 1. 8 is not a prime because I can divide 8 by 2.

In the above algorithm,

- We first define a variable num and initialize it to 1 and a variable count=0 and put it in a loop till it reaches 100.
- Then we initialize 2 variables flag to 0 and i to 1.
- We then check if num is divisible by i, which takes up value till it reaches num. If divisible we increment flag by 1. We repeat the above step until num is greater than or equal to i.
- Then, we check whether flag is equal to 2, if yes Print num and increment count by 1
- After that num increments by 1 and the above process continues till count reaches 100

1 UpvotesUpvote |
0 DownvotesDownvote |

- Algorithm and Flowchart for Matrix addition [7157 Views]
- Bellman-Ford Algorithm with Example [8529 Views]
- Debug Javascript in Iphone or IPad iOS [2140 Views]
- How To Find Compound Interest Using C++ Program [89 Views]
- Palindrome Checker in python using deque [44 Views]

- Algorithm to find whether number is Armstrong Number or Not [39856 Views]
- How To Win Ludo King Game Every Time [39104 Views]
- Jio Phone hang on LOGO problem Solution - Hard Reset Jio Phone [27502 Views]
- Knuth-Morris-Pratt (KMP) Substring Search Algorithm with Java Example [27468 Views]
- FlowChart and Algorithm to find Whether a Number is Even or Odd [19872 Views]