#25 Python Tutorial for Beginners | Prime Number in Python

preview_player
Показать описание
Check out our courses:

Coupon: TELUSKO10 (10% Discount)

Coupon: TELUSKO10 (10% Discount)

Coupon: TELUSKO20 (20% Discount)

Udemy Courses:

For More Queries WhatsApp or Call on : +919008963671

Рекомендации по теме
Комментарии
Автор

Sir you always simplifies the problems in a very easy way, even a slow learner like me get the logics in first attempt.This is the real quality of great teacher.Thankyou.. Jai Hind🇮🇳

BukkaReddy..
Автор

x = int (input ("enter your number ? "))
for i in range (2, x):
if x%i==0:
print ('its a non prime number')
break
else:
print ('its a prime number')

pannadarao
Автор

Finally, a clear, concise, easily understood explanation for finding prime. Thanx.

johnhazlett
Автор

your python series are great sir, thanks for this

aakashtiwari
Автор

x=int(input("input your number\n"))
for i in range(2, int(x/2+1)):
if(x%i==0):
print("enter number not prime number")
break;
else:
print("enter number is a prime numbere\n")
print("SIR YOU RELAY HELP US SO MUCH SO THANK YOU FOR YOUR EFFORT")

sahebsarkar
Автор

one of the Best star teacher on YouTube hats off to you sir

jitendrakumar-nfxz
Автор

n=int(input("Enter a number"))
c=0
for i in range(1, n+1):
if n%i==0:
c+=1
if c==2:
print("prime")
else:
print("Not prime")

jayantakumarpal
Автор

Great Mr Naveen, this is the real trick if you want to be a good programmer..Good job, , , keep doing this, People need to learn.

forsake
Автор

My Prime code, for checking prime number there is no need to run the loop till its number. We an even achieve it by running the loop till (num/2)+1. In this way you can reduce half of the effort. Will be useful while checking for large numbers.


Code :


num = int(input("check number is prime or not :"))
for i in range(2, int(num/2)+1):
if num % i == 0:
print("not prime")
break
else:
print("prime")

k.manideep
Автор

if you want to try with function:


def prime(num):
for i in range(2, num):
if num % i == 0:
return "not a prime number"
else:
return "prime number"
num = int(input("enter a number: "))
print(prime(num))

sivakrishna
Автор

Your beginner video's are best in YouTube sir, in this lockdown wanted to be productive and thought of learning python after a lot of playlists and channels your channel has got all the information and tutorial a beginner needs

a.v.n.ssripavan
Автор

n=int(input("enter a number"))
for i in range(2, int(n/2)):
if(n%i==0):
print("not prime")
break
else:
print("prime")

snapindia
Автор

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

if a <= 1:
print(a, "is not prime")
else:
for i in range(2, a // 2 + 1):
if a % i == 0:
print(a, "is not prime")
break
else:
print(a, "is prime")



This is the most right python program

AbhijitDasTitu
Автор

to my knowledge this is efficient:)
x=int(input("enter a vlaue"))
for i in range(2, x):
if x%i==0:
print("not a prime")
break
else:
print("is a prime")

shivan
Автор

count = 0
n = int(input("Enter a number:"))
for i in range(1, n+1):
if n % i == 0:
count +=1
if count == 2:
print(n, "is a Prime number")
else:
print(n, "is Not a Prime number")

vickysing_n
Автор

num = int(input("Enter any number "))
if num>1:
for i in range(2, num):
if num%i==0:
print("Not a prime number.")
break
else:
print('it is a prime number')

else:
print('not a prime number')

chughprabhkirat
Автор

n=int(input("enter the value of n"))
if(n==1):
print("it is not prime number")
for i in range(2, n-1):
if(n%i==0):
print("it is not a prime number")
break
else:
print("it is a prime number")

BDIt-vjhk
Автор

Your tutorials makes coding life much more simple :)

seanpereira
Автор

Little more optimized..
import math
num = int(input("Enter the number:"))
n = math.floor(math.sqrt(num))
for i in range(2, n + 1, 1):
if num % i == 0:
print("The number is not prime, divisible by", i)
break
else:
print("The number is prime")

rahul
Автор

at first i used to hate for loop and while loop and after watching your and seeing the examples i used to love them sir thanks a lot❤️btw i am aman raj😀

JoyBoy_