Algorithm 1
Algorithm 1
Prime Number
Step-1: Start
Step-2: Input n
1. r = n mod i
2. If r = 0
a. Count = Count+1
b. break
3. i = i+1
Else
Step-6: End if
Step-7: Stop
Leap Year
Step-1: Start
else
else
Step-4: End if
Step-5: Stop
1
Fibonacci series
Step-1: Start
1. third = first+second
2. print “ third ”
3. first = second
4. second = third
5. i = i+1
Step-8: Stop
Palindrome number
Step-1: Start
Step-4: copy = N
1. digit = N%10
2. reverse = reverse*10+digit
3. N = N/10
else
Step-7: End if
Step-8: Stop
2
Largest and Smallest of n numbers
Step-1: Start
1. Input num[i]
Step-9: Stop
Step-2: Input n
1. print “ n ”
Step-4: else
1. Set two pointers: one (lower) star ng from n−1 and the other (upper) from n+1.
2. Check if the lower number is prime.
a. If prime then
i. Print “lower”
3. Check if the upper number is prime.
a. If prime then
i. Print “ upper ”
4. If neither is prime then
a. lower = lower -1
b. upper = upper +1
5. The loop con nues un l one of the pointers finds a prime number.
Step-9: End if
Step-10: Stop
3
Decimal to Binary
Step-1: Start
Step-7: Stop
Sin(x) Series
sin(x) = x - x^3/3! + x^5/5! - x^7/7! + ...
Step-1: Start
1. fact = factorial of j
2. sum = sum + ((-1)^i)*(x^j)/fact
Step-8: Stop
4
Goldberg Conjecture
Step-1: Start
Step-4: for i = 1 to n
1. if i=prime then
a. if (n-i) = prime then
1. Print “ The number can br expressed as the sum of two prime number ”
Step-5: End if
Step-6: Stop
Armstrong Number
Step-1: Start
Step-3: Input n
1. n = n/10
2. count = count + 1
Step-7: n = temp
1. dig = n mod 10
2. s = s + (dig to the power count)
3. n = n/10
Else
Step-11: End if
Step-12: Stop