No video

Check if given number is Prime Number | Java

  Рет қаралды 201,198

B Tech Computer Science

B Tech Computer Science

Күн бұрын

#Java #CoreJava #Collections #javaForBeginners Check out my Anime Store - bit.ly/3rXvlqk
Subscribe to my channel so that you do not miss any topic.
The phone I used to record - amzn.to/34V1uqX
Phone stand used - amzn.to/3igP9QZ
Lighting I used - amzn.to/3IpYyQO
My laptop - amzn.to/3L1gt1Z
My gaming Keyboard - amzn.to/3Jt66mY
My gaming Mouse - amzn.to/36B4eKE
Headphones - amzn.to/3u3RnbC
Program link - musclecode.blo...
My other videos-
Finding Reverse of a Number - • Finding Reverse of a N...
Check if given number is Prime Number - • Check if given number ...
Finding Minimum and Maximum value from an Array - • Finding Minimum and Ma...
Area and Perimeter of Rectangle - • Area and Perimeter of ...
Program to check if a string is Palindrome - • Palindrome | Program ...
Find sum of digits of a number - • Find sum of digits of ...
Count the number of Digits of a Number - • Count the number of Di...
Java program to print Fibonacci Series - • Java program to print ...
Find Factorial of a number - • Find Factorial of a nu...
Check if a given year is Leap Year - • Check if a given year...
C++ program to Swap two numbers (Using extra variable) - • C++ program to Swap tw...
C++ program to find if a number is ODD or EVEN - • C++ program to find if...
C++ program to find Quotient and Remainder - • C++ program to find Qu...
C++ program to find Sum, Difference, Product and Divison of two numbers - • C++ program to find Su...

Пікірлер: 147
@aarulmozhinandhini1540
@aarulmozhinandhini1540 3 жыл бұрын
I request u to post more videos like this....thanks to you i am able explain the logic clearly in my TCS interview 😁 and also got selected...thank you so much bro❤️
@BTechComputerScience
@BTechComputerScience 3 жыл бұрын
Hey Congratulations, knowing someone has been blessed because of my videos makes me so happy. Thank you so much for taking the time to comment.
@BTechComputerScience
@BTechComputerScience 3 жыл бұрын
I am caught up with my work, but u just inspired me to make more videos.
@aarulmozhinandhini1540
@aarulmozhinandhini1540 3 жыл бұрын
@@BTechComputerScience its my pleasure ❤️
@aarulmozhinandhini1540
@aarulmozhinandhini1540 3 жыл бұрын
@@BTechComputerScience i hope ur videos will be helping a lots of people....ur way of explaining is more clear and easy to understand...so please consider this to add more videos in ur channel 😊
@BTechComputerScience
@BTechComputerScience 3 жыл бұрын
@@aarulmozhinandhini1540 I will surely try
@sondosalfukaha4221
@sondosalfukaha4221 2 жыл бұрын
My university & my private course didn't explain it in a good way so I don't understand anything until seeing this video, a lot of thanks, man.
@sowmyamahadev18
@sowmyamahadev18 11 ай бұрын
Thankyou. Fully understood. Keep posting vedios on Java. Simply easy to understand the way you teach. All is well.
@TheMatrixOwl
@TheMatrixOwl 2 жыл бұрын
Thank you so much. You simulated the logic on paper and that made me understand it better. Keep it up!
@honeybharati9660
@honeybharati9660 3 жыл бұрын
So crisp and to the point explanation...Thank yoouu!
@BrainSparksMA
@BrainSparksMA 3 жыл бұрын
Sir please make more videos on same topic like Palindrome number , angstrom number , factorial.... You explain very good ❤️❤️❤️😀
@kunalkheeva
@kunalkheeva 2 жыл бұрын
Bruh, you don’t know how many videos i watched for it, and this one is the simplest. ❤️❤️
@BTechComputerScience
@BTechComputerScience 2 жыл бұрын
Hehe... glad it helped!
@kaveridhore4398
@kaveridhore4398 Жыл бұрын
I referred so many videos for this program. After watching yours my doubt got fully solved. Thankyou so much.
@proxy5061
@proxy5061 Жыл бұрын
Yess if(n == 0 || n == 1){ It's not a prime } Else { The vedio logic , the condition inside for loop must be n/2 } for loop ➿ condition is n/2
@Shruttiiiiii
@Shruttiiiiii Жыл бұрын
Your channel deserves more Recognition 👍 Plz do post more videos
@BTechComputerScience
@BTechComputerScience Жыл бұрын
Hehe, thanks!
@badrinarayanans355
@badrinarayanans355 Жыл бұрын
Thankyou for explaining prime number concept in a clear manner.
@GamingBusterOneAndOnly
@GamingBusterOneAndOnly 2 жыл бұрын
Really the simplest explanation everrr
@SiriSha-mq3lv
@SiriSha-mq3lv 2 ай бұрын
Honestly the best explanation ever broo
@re417k.nagasri8
@re417k.nagasri8 3 жыл бұрын
Very simple approach,, tqq broo
@diamomd514
@diamomd514 2 жыл бұрын
Very good and quiet ... Keep doing... 👍👍👍
@jaganjagan7958
@jaganjagan7958 3 жыл бұрын
I think We can't find 2 as a prime number by this program..please do check with 2
@Arch-v5s
@Arch-v5s 3 жыл бұрын
9 is not a prime number because it's multiple by 3, 1, 9..
@Arch-v5s
@Arch-v5s 3 жыл бұрын
Sorry
@girlstjohnian
@girlstjohnian 2 жыл бұрын
Bro you pick up such good topics for your video, others just explain the concept and go forth, but here, you know like literally this question came in my exam, and coz of you! I got full marks!!
@BTechComputerScience
@BTechComputerScience 2 жыл бұрын
So good to hear😊❤ Keep doing great👍
@divya.s.s1688
@divya.s.s1688 3 ай бұрын
Super explanation to easy way of coding tq😊
@tejalycan1772
@tejalycan1772 8 ай бұрын
Thank you so much for clearly explaining the topic.. Please upload more videos
@saleemsadat6557
@saleemsadat6557 3 жыл бұрын
good explanation. However, your formula will disregard negative numbers. For example if you put -11, it will print true. But we know minus 11 is not prime.
@BTechComputerScience
@BTechComputerScience 3 жыл бұрын
Thanks for ur input, a 'if' statement before the loop to check input criteria would prevent it. Yes I didn't cover all test cases. Just the basics
@chandandastanti9346
@chandandastanti9346 2 жыл бұрын
Before for loop add one if(n
@karthikpranav2406
@karthikpranav2406 3 жыл бұрын
thank you so much because of you I got the confidence to code easily :)
@BTechComputerScience
@BTechComputerScience 3 жыл бұрын
Coding is very simple :)
@suchi557
@suchi557 2 жыл бұрын
Thank you so much sir it's helping me lot and now program Is very easy to me when u explained it clearly..
@BTechComputerScience
@BTechComputerScience 2 жыл бұрын
Keep learning 😃
@godson924
@godson924 2 жыл бұрын
what if we take n =2 then 2%2 = 0 so will it not give output as not prime
@k.v.prabhu1860
@k.v.prabhu1860 3 жыл бұрын
So many website theri use for loop( i=
@sharannarsinginsb
@sharannarsinginsb Жыл бұрын
Thank you so much it was really helpful. Appreciate your effort!👏
@MadhuSudhan-um2lm
@MadhuSudhan-um2lm 2 жыл бұрын
beautiful answer but there are one mistake bro , if you are entered n = 1; output is true , this is wrong step
@abidhazratzai1260
@abidhazratzai1260 3 ай бұрын
Very clear explanation thank you
@mr.badluck9521
@mr.badluck9521 2 жыл бұрын
If we take 1 as input then it is showing true as a prime number but 1 is not prime number sir so it should be false at the output .
@bhumighutke5997
@bhumighutke5997 4 ай бұрын
Thank you so much ❤ You make it look so easier....
@vinoth9891
@vinoth9891 2 жыл бұрын
Very simple and easy tq brother
@ravikantgaikwad5470
@ravikantgaikwad5470 2 жыл бұрын
I request u to post more videos like this...thank you so much ❤
@hemrajpatil782
@hemrajpatil782 2 жыл бұрын
very nice sir. it looks very easy now.
@fraoulmassresha6639
@fraoulmassresha6639 3 жыл бұрын
nice hand writing , like your font ..
@khushbusahani579
@khushbusahani579 Жыл бұрын
Thankyou so much now I can clearly understand how to print prime no. What's the logic behind this program ☀️💯
@BTechComputerScience
@BTechComputerScience Жыл бұрын
That's great!
@bharadwaj25
@bharadwaj25 Жыл бұрын
Thank you very much, you explained it in detail.
@rahulbhagwat4010
@rahulbhagwat4010 2 жыл бұрын
this was the best explanation
@nandalalsingh8082
@nandalalsingh8082 3 жыл бұрын
U are the unique one sir I could able to understand the concept very deeply Thank you sir very much❤️❤️❤️❤️❤️
@BTechComputerScience
@BTechComputerScience 3 жыл бұрын
I am glad it was helpful
@himanshujha3495
@himanshujha3495 3 жыл бұрын
cool stuff, really cool stuff
@40_shreyanbanerjee28
@40_shreyanbanerjee28 3 жыл бұрын
Thanks.. but the output should be a little bit more specified !
@ritikakumbar6670
@ritikakumbar6670 3 жыл бұрын
Superb explanation sir got it very well
@dhanashreesuryawanshi9650
@dhanashreesuryawanshi9650 3 жыл бұрын
Thank You Bro.. you made it really simple
@Laundpana__
@Laundpana__ 2 жыл бұрын
Thank you so much. you explained it in a beautiful and easy way.
@BTechComputerScience
@BTechComputerScience 2 жыл бұрын
Thank u so much!😊
@salehmsf2311
@salehmsf2311 9 ай бұрын
Good work💯
@kathimahesh2492
@kathimahesh2492 2 жыл бұрын
Super bro nice teaching
@likky1139
@likky1139 Жыл бұрын
Bro screen sarriga kanipinchadam ledhu and voice vinipinchadam ledhuu broh..
@PraveenKumar-uj2ih
@PraveenKumar-uj2ih 2 жыл бұрын
Simple Explanation
@MrFars502
@MrFars502 2 жыл бұрын
Thanks man you made it clear :)
@keertiar1922
@keertiar1922 3 жыл бұрын
Can you do programs and its output for all basic programs in java and also of different way of approaching.......
@Berrybooo
@Berrybooo 11 ай бұрын
but 2 is considered as a prime number the code will not be accurate here
@supriyagandham9604
@supriyagandham9604 3 жыл бұрын
Helpful video tq sir 👍
@kraviteja3784
@kraviteja3784 Жыл бұрын
bro why did you used util package . Can you please explain
@hussainbasha3794
@hussainbasha3794 2 жыл бұрын
Good explanation
@ramyar993
@ramyar993 Ай бұрын
why for loop i starts from 2? i refers to index right?
@BTechComputerScience
@BTechComputerScience Ай бұрын
@@ramyar993 no, here it's not index, logic to finding prime number starts from 2, we first eleminate all 2's multiple, then eleminate 3's multiple and so on...
@vlogman5657
@vlogman5657 2 жыл бұрын
thanks man! but the package prime; is really hitting me i dont get it right on blue j please respond fast
@gaddamprudhvi9737
@gaddamprudhvi9737 Жыл бұрын
nice explanation
@NaveenKumar-oc8bz
@NaveenKumar-oc8bz 2 жыл бұрын
dear sir; i got revese output Which means that which are all prime number that show all false ,which are all not prime number that show true
@NaveenKumar-oc8bz
@NaveenKumar-oc8bz 2 жыл бұрын
please explain sir i have confusion
@BTechComputerScience
@BTechComputerScience 2 жыл бұрын
Mayb u r changing ur boolean variable wrongly, please check with ur boolean variable and where u r making it false or true... if still u r unable to fix it, post ur code in the comment, I ll help u out😊
@NaveenKumar-oc8bz
@NaveenKumar-oc8bz 2 жыл бұрын
public class PrimeNum { public static void main(String[] args) { int n=7; boolean prime = true; for(int i=2;n>i;i++) { if(n%i==0) prime=false; break; } System.out.println(prime); } } this my code but it work wrong for me sir .i got confusion .please Explain me sir
@BTechComputerScience
@BTechComputerScience 2 жыл бұрын
@@NaveenKumar-oc8bz ur break statement should be inside 'if' ... u missed the '{' and '}' Since ur break statement is inside for loop and not the 'if' statement, ur loop is breaking at first iteration.
@NaveenKumar-oc8bz
@NaveenKumar-oc8bz 2 жыл бұрын
Thank you lot sir thank sir thank for ur explanation. Keep rocking sir i will support you sir i will share ur video to frd also
@moni6468
@moni6468 11 ай бұрын
what will be the output for 1 and 2 ?
@shidlingaswamy4044
@shidlingaswamy4044 2 жыл бұрын
Bro good explanation. But 0 and 1 are not prime numbers if I give input as 1 or 0 for above program it will be printed as True. so please correct it
@BTechComputerScience
@BTechComputerScience 2 жыл бұрын
I have explained at basic level, I have not solved the edge test cases, students should identify the edge test cases like u did and try to solve it. That's how we learn!
@shidlingaswamy4044
@shidlingaswamy4044 2 жыл бұрын
@@BTechComputerScience K Thank you
@karthickmurugan9260
@karthickmurugan9260 Жыл бұрын
Bro make video for how to trace out the program !
@kdoss5285
@kdoss5285 2 жыл бұрын
Very very thank you sir...
@varunshadow8588
@varunshadow8588 3 жыл бұрын
Super bro ❤️
@niranjanravichandran8931
@niranjanravichandran8931 Жыл бұрын
Bro what happens if I give n = 2?
@vaibhavkumar4951
@vaibhavkumar4951 Жыл бұрын
bhai ye programme 2 ke liye fail ho jaega .......isme extra condition add krni pdegi
@proxy5061
@proxy5061 Жыл бұрын
Kaisaaa woo kaisa
@debaduttasahu9917
@debaduttasahu9917 Жыл бұрын
great sir
@Decodetricks_By_Ayush
@Decodetricks_By_Ayush 2 жыл бұрын
Bro your code go wrong if you input 2
@quantumapex4897
@quantumapex4897 2 жыл бұрын
Tomorrow I have exam thank you sir for your effort🙏
@BTechComputerScience
@BTechComputerScience 2 жыл бұрын
Do well!
@JAYARAMANca
@JAYARAMANca 2 жыл бұрын
In case of 15 is not eligible for this method
@chiranjeevinarada1704
@chiranjeevinarada1704 Жыл бұрын
Bro Please do video on SQL queries plz plz
@user-bu5qs3ir7x
@user-bu5qs3ir7x Жыл бұрын
sir why you can not take 9 then u will took 9 it will print is a prime but it is not a prime
@BTechComputerScience
@BTechComputerScience Жыл бұрын
It will not print 9 as prime 😊
@malavikasadasivan8291
@malavikasadasivan8291 3 жыл бұрын
What is the output if n=4 can you show
@anjeshwar1
@anjeshwar1 9 ай бұрын
this program explains even or odd not prime. Give input as 9,15 it gives true but 9,15 are not prime numbers. sorry to say, check the programs with different inputs and upload bro. Most people doesn't checks it and follows the programs blindly.
@BTechComputerScience
@BTechComputerScience 9 ай бұрын
Please check ur program properly
@dhanushcheni9480
@dhanushcheni9480 2 жыл бұрын
In.. Your code we take... 2 then.. Its show not prime.. Number but 2 is prime number... Know... Then.. What we do
@BTechComputerScience
@BTechComputerScience 2 жыл бұрын
Think about the logic, I know u can solve it! I just gave the basic logic for the program 😊
@Moonart.shorts
@Moonart.shorts 3 жыл бұрын
Thank you❣️
@rajeshkrishna1422
@rajeshkrishna1422 Жыл бұрын
Sir can u please explain me kaprekar number?
@sallyxx23
@sallyxx23 2 жыл бұрын
Thanks 😊
@mithank2666
@mithank2666 2 жыл бұрын
thank you so much
@HR-pz7ts
@HR-pz7ts Жыл бұрын
Codechef says this approach is wrong
@gaurav1005
@gaurav1005 3 жыл бұрын
why we are running it from i=2 in for loop ?
@BTechComputerScience
@BTechComputerScience 3 жыл бұрын
Since all numbers are divisible by 1, we are avoiding it to save some computational time. Also the given number will always be divisible by 1 and N and we need not care, all we have to see is if any other between 1 and N divides N to prove its NOT PRIME.
@gaurav1005
@gaurav1005 3 жыл бұрын
@@BTechComputerScience thank you soo much sir
@thesharks4676
@thesharks4676 2 жыл бұрын
And then put the video for sum of primenumber ina given sequence
@LYJManchesterUnited
@LYJManchesterUnited 3 жыл бұрын
if you enter 0 or 1 it says it's a prime number
@BTechComputerScience
@BTechComputerScience 3 жыл бұрын
It's great that u have noticed this, 0 and 1 are neither prime nor composite, for beginner level this program is fine. I really appreciate it, after roughly 5.8k views, u are the first person to notice. Just add this before the 'for' loop if(n == 0 || n == 1) { System.out.print("Neither prime nor composite"); System.exit(0); }
@sweetani9378
@sweetani9378 Жыл бұрын
Okay bro check n=2
@omkaryadav7445
@omkaryadav7445 Жыл бұрын
OG❤
@offthehook5042
@offthehook5042 2 жыл бұрын
I want with inheritance
@programmerhub824
@programmerhub824 Жыл бұрын
0 and 1 ke case me fail ho jayega yeh program
@proxy5061
@proxy5061 Жыл бұрын
Yess if(n == 0 || n == 1){ It's not a prime } Else { The vedio logic , the condition inside for loop must be n/2 }
@bindureddy2885
@bindureddy2885 2 жыл бұрын
Nice explanation but video is not getting clear
@BTechComputerScience
@BTechComputerScience 2 жыл бұрын
Thanks and sorry about that! Maybe its a little better at higher resolution.
@roggamerg531gt
@roggamerg531gt Жыл бұрын
what about 0 and 1
@proxy5061
@proxy5061 Жыл бұрын
Yess if(n == 0 || n == 1){ It's not a prime } Else { The vedio logic , the condition inside for loop must be n/2 }
@WolfPaul
@WolfPaul 2 жыл бұрын
wow.
@janasenakonaseema9339
@janasenakonaseema9339 Жыл бұрын
java basic
@rudranrock7658
@rudranrock7658 3 жыл бұрын
🤙💫
@crazyeditor1782
@crazyeditor1782 Жыл бұрын
😜
@hodophilenafis3207
@hodophilenafis3207 3 жыл бұрын
raza sir
@durgaprasadduvvu1781
@durgaprasadduvvu1781 3 жыл бұрын
bro 9 is not prime 1 3 9
@BTechComputerScience
@BTechComputerScience 3 жыл бұрын
Yes, it's not prime. What happened?
@sulaimansha6189
@sulaimansha6189 3 жыл бұрын
What if number is 2
@BTechComputerScience
@BTechComputerScience 3 жыл бұрын
Since 2 is divisible by 1 and the number itself (2), it is a prime number :)
@giridatta1525
@giridatta1525 3 жыл бұрын
how to pass n=2 into loop?
@shaikhmerchant7625
@shaikhmerchant7625 3 жыл бұрын
Sir plz provide your email
@rehanhussan
@rehanhussan 2 жыл бұрын
System.out.println("Thanks");
@BTechComputerScience
@BTechComputerScience 2 жыл бұрын
True coder🤘
@Arch-v5s
@Arch-v5s 3 жыл бұрын
9 is not a prime number because it's multiple by 3, 1, 9..
@nandalalsingh8082
@nandalalsingh8082 3 жыл бұрын
I think you have not watched the video fully
Finding Reverse of a Number | Java | Detailed Explanation
11:36
B Tech Computer Science
Рет қаралды 50 М.
Java Program #6 -  Find Prime Numbers in Java
8:49
Programming For Beginners
Рет қаралды 9 М.
The Joker kisses Harley Quinn underwater!#Harley Quinn #joker
00:49
Harley Quinn with the Joker
Рет қаралды 23 МЛН
Please Help Barry Choose His Real Son
00:23
Garri Creative
Рет қаралды 23 МЛН
Palindrome |  Program to check if a string is Palindrome | Java
9:31
B Tech Computer Science
Рет қаралды 109 М.
How to: Work at Google - Example Coding/Engineering Interview
24:02
Life at Google
Рет қаралды 7 МЛН
Fastest Way to Learn ANY Programming Language: 80-20 rule
8:24
Sahil & Sarra
Рет қаралды 832 М.
Program to Check Whether A Number is Prime or Not in Java by Deepak
8:39
Smart Programming
Рет қаралды 551 М.
5.16 Armstrong Number in Java
6:01
Telusko
Рет қаралды 311 М.
The Joker kisses Harley Quinn underwater!#Harley Quinn #joker
00:49
Harley Quinn with the Joker
Рет қаралды 23 МЛН