Python Tutorial - Prime Numbers | Program To Check Entered Number is Prime or Not

Поділитися
Вставка
  • Опубліковано 21 жов 2024

КОМЕНТАРІ • 241

  • @manishbaburaisingh1985
    @manishbaburaisingh1985 6 років тому +27

    Simple and good .need more videos on the programs which are general in interviews

  • @priyankavaidya110
    @priyankavaidya110 3 роки тому +6

    Thank you so much for explaining with example. I was confused with for loop. Now ,it is completely clear to me ....how it works.

  • @Joshi_Vibes
    @Joshi_Vibes 4 роки тому +6

    after watching so mny videos i understood from yours ty:-):-)

    • @AmulsAcademy
      @AmulsAcademy  4 роки тому +1

      Glad to hear that :)

    • @Engineer9060
      @Engineer9060 2 роки тому

      how you understood tell me also its totally wrong code ,it is for even no. when you will do it for 21 it will show prime but 21 is not prime....

  • @omkar1592
    @omkar1592 3 роки тому +1

    your voice and explanation both are amazing

  • @shruthisagar7677
    @shruthisagar7677 6 років тому +7

    Hi . Very well explained . Easy to understand and solve it
    Thank You

  • @abhishekpani6735
    @abhishekpani6735 3 роки тому +4

    Thanku so much .. it really helped me...❤️

  • @radiagulzan
    @radiagulzan 5 років тому +7

    Thank you so much! But, what do we do with the input 2 in the end?

  • @galadimatimothy802
    @galadimatimothy802 5 років тому +6

    Well done.. Perfectly explained

  • @dudeinspace1491
    @dudeinspace1491 3 роки тому

    Ur voice keeps entertaining..!

  • @amansharma-it4df
    @amansharma-it4df Рік тому

    Very good video you solve me very very big problem thank you very much again

  • @rajangymtech.7073
    @rajangymtech.7073 2 роки тому

    Your teching ideas mind blowing

  • @Pikachu-dw3qk
    @Pikachu-dw3qk 3 роки тому +5

    mam please say how this technique applies if we give input number 2 ??? for other numbers i understood this code perfectly except number 2 case please reply mam

    • @AmulsAcademy
      @AmulsAcademy  3 роки тому +5

      When input is 2, for loop body will not execute and else part will execute :)
      In for loop start is 2 and end is 2 so it won’t execute loop body :)
      And because for loop is not terminated by break statement , else par will execute :)

    • @Pikachu-dw3qk
      @Pikachu-dw3qk 3 роки тому +1

      @@AmulsAcademy ok mam i got it thanks for the reply

  • @unclerojelio6320
    @unclerojelio6320 4 роки тому +10

    There is not need to check the for divisors greater than sqrt(num). You can increase the efficiency of this program quite a bit by changing the for loop to:
    for i in range(2, sqrt(num))

  • @darthsidious1137
    @darthsidious1137 5 років тому +4

    Wish I would of found this video a couple hours ago. Had to settle with the brute force method for my assignment.

  • @ganpatinatrajan5890
    @ganpatinatrajan5890 Рік тому

    Excellent Explanations...👍👍👍

  • @gandrakavya8201
    @gandrakavya8201 2 роки тому

    thank you mam!!!....ur vedios make me to solve programs on my own :)

  • @hmx21
    @hmx21 3 роки тому +18

    You don't need to check all the way till num, running the loop till num//2 would get you the same result.

    • @DrRCB
      @DrRCB 2 роки тому +2

      yes. However there is still a shorter range than n/2.

    • @okechukwuerinne2039
      @okechukwuerinne2039 2 роки тому +1

      I tried this and got a wrong output. I got "4 is a prime number." Perhaps I messed up the program somewhere.

    • @lolbaba7403
      @lolbaba7403 2 роки тому

      @@okechukwuerinne2039
      number=2
      divisor=2
      if number ==divisor or number==1:
      print("prime number")
      else:
      if number%divisor==0:
      print("Not prine")
      else:
      print("Prime")
      This is code for short range.
      But when it comes to find prime number in some range then this code is wrong.

    • @shayaanrk
      @shayaanrk Рік тому

      @@okechukwuerinne2039 for such basic exceptions, you should have already added another if statement.
      if num%2==0 then print False

  • @trundlingwithjoy2237
    @trundlingwithjoy2237 3 роки тому +2

    thank you for this keep up the good work

  • @shivabagareddy9195
    @shivabagareddy9195 3 роки тому +1

    Good explanation with impressive voice.....
    Want to listen more of your voice:)

  • @vidithnarayana2346
    @vidithnarayana2346 4 роки тому +1

    I like your explanation 👌👌 TQ so much

  • @paviyug
    @paviyug 4 роки тому +1

    you explained it very Well

  • @SanOp-zx1pc
    @SanOp-zx1pc 11 місяців тому +2

    this code is wrong input numbers like 27,321,etc...
    which are not divisible by 2 but are not prime numbers....
    still the programme gives the numbers to be prime
    correct programme code
    num=int(input('Enter a positive number :'))
    if num > 1:
    # Iterate from 2 to n / 2
    for i in range(2, int(num/2)+1):
    # If num is divisible by any number between
    # 2 and n / 2, it is not prime
    if (num % i) == 0:
    print(num, "is not a prime number")
    break
    else:
    print(num, "is a prime number")
    elif num==0:
    print(num,'is neither prime nor composite.....')
    else:
    print(num, "is not a prime number")

    • @SanOp-zx1pc
      @SanOp-zx1pc 9 місяців тому +1

      @@A4KSHAT Bro is 27 a prime number???
      ofcourse not , so how it is showing that it is a prime number

    • @A4KSHAT
      @A4KSHAT 9 місяців тому

      @@SanOp-zx1pc i am sorry it is show it is not a prime number

  • @okechukwuerinne2039
    @okechukwuerinne2039 2 роки тому +1

    Thank you so much for this; it was a life saver.

  • @jnageswararao8574
    @jnageswararao8574 2 роки тому

    U voice is good....

  • @possiblesupport1029
    @possiblesupport1029 2 роки тому

    Super explaination on the whole youtube

  • @Raja-tt4ll
    @Raja-tt4ll 4 роки тому +1

    Great explanation thanks

  • @daniellejdevlin8882
    @daniellejdevlin8882 3 роки тому +4

    Can you explain why number=2 shows up as prime in the code when 2÷2=0? I know 2 is prime

  • @listentosilently
    @listentosilently 3 роки тому +1

    Video is good
    #TECH_INTERVIEW_PREPRATION

  • @varshacm1444
    @varshacm1444 4 роки тому +1

    Mam why else is straight under for loop it should be under if know mam plse do reply mam

    • @AmulsAcademy
      @AmulsAcademy  4 роки тому

      We can use else case with loops also.
      Here we want else part with for loop.
      The else block just after for/while is executed only when the loop is NOT terminated by a break statement.

  • @gayathri-8-i6s
    @gayathri-8-i6s 3 роки тому +1

    Sisy.. plz put videos for sum of next 2 consecutive numbers

  • @nareshchoudhary4799
    @nareshchoudhary4799 Рік тому +1

    How to save it with which name

  • @dharmikmistry8781
    @dharmikmistry8781 4 роки тому

    It's very good 👏👏👍

  • @aniketpatil1737
    @aniketpatil1737 2 роки тому

    I am watching this masterpiece in Dec 2021

  • @ashishsinha5015
    @ashishsinha5015 4 роки тому +1

    mam why you have used else with for loop but not with if

    • @AmulsAcademy
      @AmulsAcademy  4 роки тому +1

      else case can be used with loops also :)
      here we need else part with for loop :)

  • @dharshinimagesh9591
    @dharshinimagesh9591 5 років тому +4

    hi mam,
    pl write this example with while loop .
    i hav tried many times but always stuck wit where to give the increment "i=i+1" operator .

    • @AmulsAcademy
      @AmulsAcademy  5 років тому +1

      num = int(input(":"))
      if num > 1:
      i = 2
      while i < num:
      if (num % i) == 0:
      print(num,"is not a prime number")
      break
      i =i+1
      else:
      print(num,"is a prime number")
      else:
      print(num,"is not a prime number")
      :)

    • @dharshinimagesh9591
      @dharshinimagesh9591 5 років тому +1

      @@AmulsAcademy thank u very much .
      can u pl tel me wats wrong in this code n if possible could u correct it ?

    • @dharshinimagesh9591
      @dharshinimagesh9591 5 років тому +1

      lower=int(input("lower no "))
      upper=int(input("upper no "))
      i = 2
      for num in range (upper,lower+1):
      while i < num:
      if (num % i) == 0:
      print(num,"is not a prime number")
      break
      i =i+1
      else:
      print(num,"is a prime number")
      i want to print prime no's in the intervals like this, without two for loops ..

    • @AmulsAcademy
      @AmulsAcademy  5 років тому +2

      lower=int(input("lower no "))
      upper=int(input("upper no "))
      for num in range (lower,upper+1):
      i=2
      while i < num:
      if (num % i) == 0:
      #print(num)
      print(num,"is not a prime number")
      break
      i =i+1
      else:
      print(num,"is a prime number")
      Try this :)

    • @dharshinimagesh9591
      @dharshinimagesh9591 5 років тому +2

      ​@@AmulsAcademy thank u very much mam . I've identified my mistake 🙏
      u dont believe me , i have been fighting with this prime no's prg for past TEN days and I've found ur videos accidentally and i havnt expected this much response from u .
      u r really a respectful and a responsible teacher .🙏

  • @pravaalc8409
    @pravaalc8409 3 роки тому +2

    Nicely explained, but if i enter number as 2, the code does not execute. please help

    • @AmulsAcademy
      @AmulsAcademy  3 роки тому +4

      Thank you :)
      No it will work properly for input 2.

    • @pravaalc8409
      @pravaalc8409 3 роки тому +1

      @@AmulsAcademy thank you. noticed indentation was not properly placed in my code

    • @AmulsAcademy
      @AmulsAcademy  3 роки тому

      Yes indentation matters a lot in python :)

  • @crewmate3031
    @crewmate3031 4 роки тому +2

    Mam why did u use break. Can u tell me the use of it please 🙏🙏

    • @AmulsAcademy
      @AmulsAcademy  4 роки тому

      if you want to exit from the loop then you can use break inside the loop.
      Execute the program without break you can see the difference :)

    • @crewmate3031
      @crewmate3031 4 роки тому

      @@AmulsAcademy oo ok mam thanks

  • @trundlingwithjoy2237
    @trundlingwithjoy2237 3 роки тому +1

    maam but if we put 9 it is showing that it is a prime number but as we know that it is not a prime number.....maam how to solve this problem?/

  • @Sandeep-sh7uc
    @Sandeep-sh7uc 4 місяці тому

    You wrote print(num,"is not a prime number" ) in FOR loop why it is not printing for num number of times

  • @bakrymohamed8711
    @bakrymohamed8711 4 роки тому +1

    my teacher I think we don't need the break statement
    so that after the if condition becomes false the for else will work

    • @AmulsAcademy
      @AmulsAcademy  4 роки тому +1

      The else block just after for/while is executed only when the loop is NOT terminated by a break statement.
      So you need to break statement here.
      Note: remove break and try to execute the program.

    • @bakrymohamed8711
      @bakrymohamed8711 4 роки тому

      @@AmulsAcademy right

  • @nishasrinivasan4621
    @nishasrinivasan4621 4 роки тому +1

    Thank you so much for this

  • @totansarker5460
    @totansarker5460 4 роки тому +1

    wow..
    thank you very much.

  • @smartcat5989
    @smartcat5989 Рік тому

    mam do you teach in valia ?

  • @bunnysunil
    @bunnysunil 5 років тому +4

    Madam I following your classes daily I am big fan of u
    yesterday I attended one interview
    I passed written test
    In second round they conducted system test
    But they gave to me a difficult task
    That task name is FLAMES
    I HOPE YOU KNOW THAT FLAMES CONCEPT
    before he conduct the system test
    He explained to me that FLAMES
    Take two persons name
    Cancel that common letters
    Count the remaining
    Letters
    For example total remaining letters are:(5)
    How to get this out put
    By using ptython code
    Plz explain this out madam

    • @AmulsAcademy
      @AmulsAcademy  5 років тому +5

      Try this:
      str1 = input("name1:")
      str2 = input("name2:")
      for i in str1:
      for j in str2:
      if i==j:
      str1=str1.replace(i,"",1)
      str2=str2.replace(i,"",1)
      print(i,j)
      print(str1,str2)
      print("remaining characters in str1:",len(str1))
      print("remaining characters in str2:",len(str2))
      :)

  • @umairgillani699
    @umairgillani699 5 років тому +1

    how about if we want to check the list of prime numbers in a range x to y, where x and y could be any range..

    • @AmulsAcademy
      @AmulsAcademy  5 років тому +1

      I did make a video on how to print prime numbers in particular range please check that :)

    • @umairgillani699
      @umairgillani699 5 років тому +1

      @@AmulsAcademy Yes watched it. It makes a good logic. Please come up with more videos like these :)

  • @lilyfullery4779
    @lilyfullery4779 3 місяці тому

    Too good ❤

  • @hetanshikothari4177
    @hetanshikothari4177 4 роки тому +1

    Here i got stuck with case number =2 here 2 modulo 2 will be 0 still it prints 2 is a prime number how does that work

    • @AmulsAcademy
      @AmulsAcademy  4 роки тому +2

      in the for loop we took range from 0 to num
      when num=2
      range becomes 2 to 2
      range(2,2)
      so it won't execute for loop body :)
      You can execute this and check
      for i in range(2,2):
      print("hello")
      else:
      print("hi")

    • @hetanshikothari4177
      @hetanshikothari4177 4 роки тому

      Amulya's Academy thank you so much for the explanation!! Got it

  • @anshumanchoudhary2658
    @anshumanchoudhary2658 2 роки тому

    a=int(input("enter:"))
    if (a%2==0) or (a%3==0):

    print("it is not prime number")
    else:
    print("it is prime")
    this is write or wrong

  • @ameyashetty1441
    @ameyashetty1441 3 роки тому +2

    hey 2 is a prime no but 2%2==0 then how does this work

    • @AmulsAcademy
      @AmulsAcademy  3 роки тому +2

      Please check for loop range, starting value and end value is same that is 2, so it won’t execute loop body 😊

    • @nandith1473
      @nandith1473 Рік тому

      @@AmulsAcademy no it's not same it becomes(2,1) right as end value is excluded

  • @ajithkumarm9446
    @ajithkumarm9446 4 роки тому +1

    Mam, why are u using for loop for all program?

    • @AmulsAcademy
      @AmulsAcademy  4 роки тому

      If you want you can use while loop also.
      :)

  • @aryavs4555
    @aryavs4555 6 років тому +4

    may i give u a suggestion
    pls run the programme and show us the output
    it will ensure that ur codes are correct

    • @AmulsAcademy
      @AmulsAcademy  6 років тому +1

      Thank you for the suggestion:)
      Didn't i show the output in this video?
      Usually i do execute my program.
      :)

    • @zizo8737
      @zizo8737 5 років тому

      Arya V S Watch the video properly she has shown the execution

  • @asrithavardhini956
    @asrithavardhini956 4 роки тому +1

    by writing your code, for number 2 it is not showing anything..please help me

    • @AmulsAcademy
      @AmulsAcademy  4 роки тому

      No it will print 2 is prime number.
      Give me the program i will check for you :)

    • @asrithavardhini956
      @asrithavardhini956 4 роки тому

      Thanks:) it's working...👍😊

  • @deepikamathur9466
    @deepikamathur9466 3 роки тому +1

    Nice mam..

  • @uk0707raptor
    @uk0707raptor Рік тому

    Mam this code is not working for number 2.

  • @mika4444
    @mika4444 3 роки тому +1

    how to check the number is a prime number in a range entered by the user????

    • @AmulsAcademy
      @AmulsAcademy  3 роки тому

      Give me an example :)

    • @mika4444
      @mika4444 3 роки тому

      @@AmulsAcademy for example...user enters the starting range and ending range...from that range we have to find which numbers are prime numbers.

  • @kairu9373
    @kairu9373 4 роки тому +5

    Even or Odd and Prime or Composite numbers are different programming logics. What you are trying to imply in here is that every number divisible by 2 is not a Prime number when 9, 15, 21 and so on are not Prime numbers and are not divisible by 2. This is unclear and confusing. The way the tutorial is being discussed has never changed and is still the same as other content creators stating they found the answer behind Prime number logics.

    • @Engineer9060
      @Engineer9060 2 роки тому +3

      you are the only one in the comment whom i found have some knowledge, other than people here are saying they are clear , its just a soln for even no. not for prime no.

    • @KimTae47016
      @KimTae47016 Рік тому +2

      I was also confused that by using this method it will print prime statements even for odd numbers..

  • @RK-jv3kw
    @RK-jv3kw 3 роки тому +1

    Are u from tamil nadu ?
    i understood well thanks for the video

    • @AmulsAcademy
      @AmulsAcademy  3 роки тому +1

      No I am from Karnataka.
      Thank you :)

    • @RK-jv3kw
      @RK-jv3kw 3 роки тому +1

      @@AmulsAcademy i am from kerala, i can easly recognise south indains

    • @AmulsAcademy
      @AmulsAcademy  3 роки тому

      Hello :)

    • @RK-jv3kw
      @RK-jv3kw 3 роки тому

      @@AmulsAcademy hello

    • @RK-jv3kw
      @RK-jv3kw 3 роки тому +1

      you are nice teacher

  • @yadavj12
    @yadavj12 2 роки тому

    Hello dear we have to find out a prime number or not means there is three conditions can you please explain those three conditions

  • @bhavithasulax.
    @bhavithasulax. 3 роки тому +1

    Mam how can we print those prime numbers

  • @sandeepsinghnegi9220
    @sandeepsinghnegi9220 6 років тому +1

    please help
    i am getting 55 as prime number.
    by writing below code.
    num= int(input("enter any number"))
    for i in range(2, num):
    if (num % i) == 0:
    print (num,' number is not prime')
    break
    else:
    print (num,' number is prime')
    break

    • @AmulsAcademy
      @AmulsAcademy  6 років тому

      num= int(input("enter any number"))
      for i in range(2, num):
      if (num % i) == 0:
      print (num,' number is not prime')
      break
      else:
      print (num,' number is prime')
      Now check whether it will give correct output or not :)

    • @sandeepsinghnegi9220
      @sandeepsinghnegi9220 6 років тому

      num = int(input("enter number to check prime number : .. "))
      for i in range(2,num):
      if (num % i ) == 0:
      print (num,"not prime")
      break
      else:
      print(num,"number is prime")

  • @shivprakashyadav3814
    @shivprakashyadav3814 3 роки тому +1

    why else is used for for loop not for if

    • @AmulsAcademy
      @AmulsAcademy  3 роки тому

      We can use else case with loops :)

  • @tuomasbazzan1523
    @tuomasbazzan1523 3 роки тому +1

    Thank you

  • @tanweerkarzai7355
    @tanweerkarzai7355 3 роки тому

    withought using breal ,how to solve it

  • @kryptonboron6104
    @kryptonboron6104 3 роки тому +1

    Mam...it is not working for *21* . What to do? But thanks for the video mam

    • @AmulsAcademy
      @AmulsAcademy  3 роки тому

      21 is not prime number right ? What is the problem ? :)

    • @kryptonboron6104
      @kryptonboron6104 3 роки тому

      Mam....When I entered 21, then it checks and says that *21 is prime* . Then I again tried designing a new code for it. Thanks for your reply mam😄

  • @bibekanandasahoo3497
    @bibekanandasahoo3497 2 роки тому

    How I write this code in list comprehension method

  • @muskaangupta4915
    @muskaangupta4915 2 роки тому

    % k bd wala else iff k indention m aan chahiy th na jo for k nicje ku aara

  • @jeetgupta2286
    @jeetgupta2286 4 роки тому +1

    Thank u didi ❣️❣️🙏🙏

  • @TJ-wo1xt
    @TJ-wo1xt 2 роки тому

    nice one.

  • @Unidentifying
    @Unidentifying 4 роки тому +1

    How to do this without using break ?

  • @urvi23
    @urvi23 2 роки тому +1

    Mam if we check no 2 how it will work?

  • @anusmitasamanta2608
    @anusmitasamanta2608 4 роки тому +1

    amazing ...

  • @byjusCOM-pw7xn
    @byjusCOM-pw7xn 4 роки тому

    Ur range function is not working may I know the reason

  • @prasanthkrishnam62
    @prasanthkrishnam62 3 роки тому +1

    How to get a preceding number of a given number

  • @vishaljat4398
    @vishaljat4398 2 роки тому

    Thank you❤

  • @swatimaskawade5321
    @swatimaskawade5321 2 роки тому

    can't we add int in the input statement ?🤔🤔🤔🤔🤔🤔

  • @ramurachineni2255
    @ramurachineni2255 3 роки тому

    How to do same program with while loop

  • @gowthamselvaraj7793
    @gowthamselvaraj7793 Рік тому

    Please explain Circular prime number in python mam

  • @itzscytesalpha2963
    @itzscytesalpha2963 3 роки тому +1

    Nice vid

  • @ananddarshan1114
    @ananddarshan1114 2 роки тому

    then why the hell my program says 9 and 15 are prime number when i write the same program as yours.

  • @rahuljuneja1185
    @rahuljuneja1185 6 років тому +5

    According to your code,it starts dividing by 2.
    So,2%2==0
    Then according to your code,2 should not be a prime number

    • @AmulsAcademy
      @AmulsAcademy  6 років тому +6

      No because in the for loop range will become 2 to 2 at that time .
      so it won't execute for loop directly goes to else part
      :)

    • @rahuljuneja1185
      @rahuljuneja1185 6 років тому +1

      Amuls Academy Thanks.

    • @rohitjoshi1777
      @rohitjoshi1777 5 років тому +1

      @@AmulsAcademy Did not understood range become 2 to 2 at that time

  • @komaljaswani7497
    @komaljaswani7497 4 роки тому +1

    Hi! Can you please make a video on the question: If a list in python has mix of strings & numbers, how will you make separate lists of strings & numbers? I saw ord() for getting ASCII code in python & chr() for converting ASCII codes to characters somewhere & tried to use them to get answer of this question but it did not work!! :(

    • @shayaanrk
      @shayaanrk Рік тому

      strings are sortd out by str(input) while numbers are sorted out by int(input)

  • @Engineer9060
    @Engineer9060 2 роки тому

    wrong concept .plz correct it acc to uyou when i will take 21 as ainput it will show it is prime no. as 21%2==1 but 21 is not a prime nno. ur soln is for even no.

  • @nabeelmalik.4714
    @nabeelmalik.4714 5 років тому

    If we use negative value then error occur...

  • @vickykolle8821
    @vickykolle8821 6 років тому +2

    Wt happend if we not type a break

    • @AmulsAcademy
      @AmulsAcademy  5 років тому +1

      you won't get proper output:)
      When we get divisor of given number then we know that number is not prime so we need to come out of the loop that's why we used break
      :)

  • @pillarikala266
    @pillarikala266 4 роки тому

    Plz tell with while loop

  • @addictedroaster1573
    @addictedroaster1573 3 роки тому +1

    Instead of this large code..
    We can do.. Num modulus 2 Or 3....remainder not eaual to 0 then it's PRIME NUMBER

    • @AmulsAcademy
      @AmulsAcademy  3 роки тому

      That’s what we are doing here 😊

    • @addictedroaster1573
      @addictedroaster1573 3 роки тому

      @@AmulsAcademy please make video on python interview programming question..
      But not mcq... Something like paragraph narrated question....
      Need it because I am final year student.. Please

    • @Engineer9060
      @Engineer9060 2 роки тому

      @@AmulsAcademy sry but i thinks its a wrong code bcz for 21,9 it will show prime.

  • @ahinav.s1925
    @ahinav.s1925 2 роки тому

    Thanks

  • @itzboyon6983
    @itzboyon6983 4 роки тому

    but if i input 2 it comes out nothing, i know it is a prime number

  • @kratishrivastava6984
    @kratishrivastava6984 6 років тому +4

    plz tell me if num = 2

    • @AmulsAcademy
      @AmulsAcademy  6 років тому +1

      2 is a prime number:)

    • @babusingh7837
      @babusingh7837 6 років тому +5

      there is some mistake in your code see carefully

    • @vasudevareddy6749
      @vasudevareddy6749 5 років тому

      @kumari sonali ,code is working fine,give lower bound as 2,then it will print including with 2

  • @ryder3099
    @ryder3099 3 роки тому

    One correction it is remainder not reminder

  • @manuaugustine750
    @manuaugustine750 5 років тому +1

    try 15 and see what output you will get

  • @bloodbath8804
    @bloodbath8804 4 роки тому +1

    while True:
    print(" thankyou very much")

  • @r4d1calwr4th7
    @r4d1calwr4th7 5 років тому +1

    try 15 it is showing a prime no.

    • @AmulsAcademy
      @AmulsAcademy  5 років тому +1

      No it won't print 15 as prime number
      :)

  • @0SIGMA
    @0SIGMA 3 роки тому

    TYSM!!

  • @ashokkumar-fl4hc
    @ashokkumar-fl4hc 5 років тому +1

    As per your code, I given 111 and 333 then it is showing both prime and not prime, don't know why it is showing like that. CODE: #For checking prime number
    num = int(input("Enter the number:"))
    if num>1:
    for i in range(2,num):
    if (num%i)==0:
    print(num, "it is not a prime number")
    break
    else:
    print(num, "It is prime number")

    • @AmulsAcademy
      @AmulsAcademy  5 років тому +1

      else is for, for loop not for if condition.
      num = int(input("Enter the number:"))
      if num>1:
      for i in range(2,num):
      if (num%i)==0:
      print(num, "it is not a prime number")
      break
      else:
      print(num, "It is prime number")
      :)

    • @vikashkumargupta3685
      @vikashkumargupta3685 5 років тому

      Same

  • @nagarani.g1694
    @nagarani.g1694 3 роки тому

    plese insert by with alagorithm

  • @shivameher3787
    @shivameher3787 4 роки тому +1

    if num=2
    then the remainder will become zero
    so how it is a prime
    anyone??

    • @AmulsAcademy
      @AmulsAcademy  4 роки тому

      when num=2 it won't execute the for loop body.
      range(2,num) so it will become range(2,2) it won't give any value.
      :)

    • @itsmeaman143
      @itsmeaman143 4 роки тому

      So what shall we do ao that it get printed 2 is a prime number?

    • @arrceusx
      @arrceusx 4 роки тому

      @@itsmeaman143 set the range from (2, num//2) it"ll return 2 as prime

  • @SevenStepsAhead
    @SevenStepsAhead 2 роки тому +1

    its remainder not reminder lmao

  • @your_daily_needs3897
    @your_daily_needs3897 Рік тому

    please check your code as its a wrong code.

  • @djquick
    @djquick 4 роки тому

    *remainder