top of page
  • Subham Das

This program checks a number is mathematically prime or not. It is a optimize program to check a number is prime number or not.



# Program to check a number is prime or not.

n = eval(input("Enter Number:"))

flag = 0

if n ==2 :

flag = 1

elif n > 2 :

i = 2

while i > n :

if n%i == 0 :

flag = 1

break

else :

flag = 0

i += 1

else :

flag = 0

if flag == 0 :

print(n,"is a prime number.")

else :

print(n,"is not a prime number.")



9 views0 comments
  • Subham Das

A palindromic number or numeral palindrome is a number that remains the same when its digits are reversed. That means if any number is reversed or we arrange the numbers in opposite order then will be same as it is. Or we can also say that number is symmetrical. Example: 131,16461 etc. We can observe that they are symmetrical.


For extracting any digits from a number, we need to divide the number with 10 and the remainder will be the last digit of that number. In these way can extract any digit from any number.


# Program to check a number is palindrome or not.

num = eval(input("Enter Number:"))

# Storing the number 'num' in a another variable.

n = num

num1 = 0

while n ! = 0 :

rem = n%10

n = n//10

# Here we are storing the reverse number in 'num1'.

num1 = num1 * 10 + rem

if num == num1 :

print("Pallindrome Number")

else :

print("Not a Pallindrome Number")






33 views3 comments
  • Subham Das

Sum of the 'n th' natural number using programming language. This program will print the series with the sum of the natural number. The series is:

1,2,3,4,5,6,7,8, ...................



# Program to print the series and the sum.

# Here enter number up to which the natural will print.

n = int(input("Enter number:"))

sum = 0

for i in range (1,n+1) :

sum += i

print(i, end=',')

print("Sum of the numbers :",sum)




3 views0 comments
logo12.PNG
bottom of page