Check if given number is Prime Number | Java

  Рет қаралды 189,401

B Tech Computer Science

B Tech Computer Science

4 жыл бұрын

#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.blogspot.com/2020/...
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...

Пікірлер: 141
@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.
@jvg9401
@jvg9401 2 жыл бұрын
Thank you so much. You simulated the logic on paper and that made me understand it better. Keep it up!
@honeybharati9660
@honeybharati9660 2 жыл бұрын
So crisp and to the point explanation...Thank yoouu!
@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!
@BrainSparksMA
@BrainSparksMA 2 жыл бұрын
Sir please make more videos on same topic like Palindrome number , angstrom number , factorial.... You explain very good ❤️❤️❤️😀
@sowmyamahadev18
@sowmyamahadev18 8 ай бұрын
Thankyou. Fully understood. Keep posting vedios on Java. Simply easy to understand the way you teach. All is well.
@badrinarayanans355
@badrinarayanans355 Жыл бұрын
Thankyou for explaining prime number concept in a clear manner.
@sharannarsinginsb
@sharannarsinginsb Жыл бұрын
Thank you so much it was really helpful. Appreciate your effort!👏
@SiriSha-mq3lv
@SiriSha-mq3lv 4 күн бұрын
Honestly the best explanation ever broo
@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
@diamomd514
@diamomd514 2 жыл бұрын
Very good and quiet ... Keep doing... 👍👍👍
@dhanashreesuryawanshi9650
@dhanashreesuryawanshi9650 3 жыл бұрын
Thank You Bro.. you made it really simple
@abidhazratzai1260
@abidhazratzai1260 Ай бұрын
Very clear explanation thank you
@re417k.nagasri8
@re417k.nagasri8 3 жыл бұрын
Very simple approach,, tqq broo
@GamingBusterOneAndOnly
@GamingBusterOneAndOnly 2 жыл бұрын
Really the simplest explanation everrr
@MrFars502
@MrFars502 2 жыл бұрын
Thanks man you made it clear :)
@karthikpranav2406
@karthikpranav2406 2 жыл бұрын
thank you so much because of you I got the confidence to code easily :)
@BTechComputerScience
@BTechComputerScience 2 жыл бұрын
Coding is very simple :)
@bhumighutke5997
@bhumighutke5997 2 ай бұрын
Thank you so much ❤ You make it look so easier....
@ravikantgaikwad5470
@ravikantgaikwad5470 Жыл бұрын
I request u to post more videos like this...thank you so much ❤
@divya.s.s1688
@divya.s.s1688 Ай бұрын
Super explanation to easy way of coding tq😊
@ritikakumbar6670
@ritikakumbar6670 3 жыл бұрын
Superb explanation sir got it very well
@himanshujha3495
@himanshujha3495 3 жыл бұрын
cool stuff, really cool stuff
@bharadwaj25
@bharadwaj25 10 ай бұрын
Thank you very much, you explained it in detail.
@tejalycan1772
@tejalycan1772 5 ай бұрын
Thank you so much for clearly explaining the topic.. Please upload more videos
@vinoth9891
@vinoth9891 2 жыл бұрын
Very simple and easy tq brother
@Shruttiiiiii
@Shruttiiiiii 10 ай бұрын
Your channel deserves more Recognition 👍 Plz do post more videos
@BTechComputerScience
@BTechComputerScience 10 ай бұрын
Hehe, thanks!
@k.v.prabhu1860
@k.v.prabhu1860 2 жыл бұрын
So many website theri use for loop( i=
@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
@rahulbhagwat4010
@rahulbhagwat4010 Жыл бұрын
this was the best explanation
@Laundpana__
@Laundpana__ Жыл бұрын
Thank you so much. you explained it in a beautiful and easy way.
@BTechComputerScience
@BTechComputerScience Жыл бұрын
Thank u so much!😊
@fraoulmassresha6639
@fraoulmassresha6639 2 жыл бұрын
nice hand writing , like your font ..
@hemrajpatil782
@hemrajpatil782 2 жыл бұрын
very nice sir. it looks very easy now.
@supriyagandham9604
@supriyagandham9604 2 жыл бұрын
Helpful video tq sir 👍
@keertiar1922
@keertiar1922 3 жыл бұрын
Can you do programs and its output for all basic programs in java and also of different way of approaching.......
@godsin924
@godsin924 2 жыл бұрын
what if we take n =2 then 2%2 = 0 so will it not give output as not prime
@40_shreyanbanerjee28
@40_shreyanbanerjee28 2 жыл бұрын
Thanks.. but the output should be a little bit more specified !
@suchi557
@suchi557 Жыл бұрын
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 Жыл бұрын
Keep learning 😃
@kathimahesh2492
@kathimahesh2492 2 жыл бұрын
Super bro nice teaching
@moni6468
@moni6468 8 ай бұрын
what will be the output for 1 and 2 ?
@karthickmurugan9260
@karthickmurugan9260 Жыл бұрын
Bro make video for how to trace out the program !
@salehmsf2311
@salehmsf2311 7 ай бұрын
Good work💯
@kdoss5285
@kdoss5285 2 жыл бұрын
Very very thank you sir...
@PraveenKumar-uj2ih
@PraveenKumar-uj2ih 2 жыл бұрын
Simple Explanation
@kraviteja3784
@kraviteja3784 Жыл бұрын
bro why did you used util package . Can you please explain
@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👍
@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 .
@malavikasadasivan8291
@malavikasadasivan8291 2 жыл бұрын
What is the output if n=4 can you show
@vlogman5657
@vlogman5657 2 жыл бұрын
thanks man! but the package prime; is really hitting me i dont get it right on blue j please respond fast
@jaganjagan7958
@jaganjagan7958 2 жыл бұрын
I think We can't find 2 as a prime number by this program..please do check with 2
@aegon199
@aegon199 3 жыл бұрын
9 is not a prime number because it's multiple by 3, 1, 9..
@aegon199
@aegon199 2 жыл бұрын
Sorry
@hussainbasha3794
@hussainbasha3794 Жыл бұрын
Good explanation
@gaddamprudhvi9737
@gaddamprudhvi9737 Жыл бұрын
nice explanation
@Moonart.shorts
@Moonart.shorts 2 жыл бұрын
Thank you❣️
@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
@chiranjeevinarada1704
@chiranjeevinarada1704 Жыл бұрын
Bro Please do video on SQL queries plz plz
@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
@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!
@varunshadow8588
@varunshadow8588 2 жыл бұрын
Super bro ❤️
@debaduttasahu9917
@debaduttasahu9917 Жыл бұрын
great sir
@mithank2666
@mithank2666 2 жыл бұрын
thank you so much
@sallyxx23
@sallyxx23 2 жыл бұрын
Thanks 😊
@likky1139
@likky1139 Жыл бұрын
Bro screen sarriga kanipinchadam ledhu and voice vinipinchadam ledhuu broh..
@niranjanravichandran8931
@niranjanravichandran8931 Жыл бұрын
Bro what happens if I give n = 2?
@quantumapex4897
@quantumapex4897 2 жыл бұрын
Tomorrow I have exam thank you sir for your effort🙏
@BTechComputerScience
@BTechComputerScience 2 жыл бұрын
Do well!
@Berrybooo
@Berrybooo 8 ай бұрын
but 2 is considered as a prime number the code will not be accurate here
@rajeshkrishna1422
@rajeshkrishna1422 Жыл бұрын
Sir can u please explain me kaprekar number?
@Decodetricks_By_Ayush
@Decodetricks_By_Ayush Жыл бұрын
Bro your code go wrong if you input 2
@JAYARAMANca
@JAYARAMANca Жыл бұрын
In case of 15 is not eligible for this method
@vaibhavkumar4951
@vaibhavkumar4951 Жыл бұрын
bhai ye programme 2 ke liye fail ho jaega .......isme extra condition add krni pdegi
@proxy5061
@proxy5061 Жыл бұрын
Kaisaaa woo kaisa
@sweetani9378
@sweetani9378 Жыл бұрын
Okay bro check n=2
@offthehook5042
@offthehook5042 Жыл бұрын
I want with inheritance
@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
@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
@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 😊
@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
@HR-pz7ts
@HR-pz7ts Жыл бұрын
Codechef says this approach is wrong
@omkaryadav7445
@omkaryadav7445 Жыл бұрын
OG❤
@thesharks4676
@thesharks4676 2 жыл бұрын
And then put the video for sum of primenumber ina given sequence
@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 😊
@WolfPaul
@WolfPaul 2 жыл бұрын
wow.
@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); }
@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 }
@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.
@rudranrock7658
@rudranrock7658 3 жыл бұрын
🤙💫
@janasenakonaseema9339
@janasenakonaseema9339 Жыл бұрын
java basic
@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 }
@hodophilenafis3207
@hodophilenafis3207 3 жыл бұрын
raza sir
@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?
@anjeshwar1
@anjeshwar1 7 ай бұрын
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 7 ай бұрын
Please check ur program properly
@durgaprasadduvvu1781
@durgaprasadduvvu1781 2 жыл бұрын
bro 9 is not prime 1 3 9
@BTechComputerScience
@BTechComputerScience 2 жыл бұрын
Yes, it's not prime. What happened?
@crazyeditor1782
@crazyeditor1782 Жыл бұрын
😜
@shaikhmerchant7625
@shaikhmerchant7625 3 жыл бұрын
Sir plz provide your email
@rehanhussan
@rehanhussan 2 жыл бұрын
System.out.println("Thanks");
@BTechComputerScience
@BTechComputerScience 2 жыл бұрын
True coder🤘
@aegon199
@aegon199 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
Рет қаралды 46 М.
Program to Check Whether A Number is Prime or Not in Java by Deepak
8:39
Smart Programming
Рет қаралды 543 М.
ТАМАЕВ vs ВЕНГАЛБИ. Самая Быстрая BMW M5 vs CLS 63
1:15:39
Асхаб Тамаев
Рет қаралды 4,7 МЛН
Super gymnastics 😍🫣
00:15
Lexa_Merin
Рет қаралды 102 МЛН
Они убрались очень быстро!
00:40
Аришнев
Рет қаралды 3,4 МЛН
The day of the sea 🌊 🤣❤️ #demariki
00:22
Demariki
Рет қаралды 57 МЛН
Program to Print All Prime Numbers between 1 to 100 in Java by Deepak
10:59
Smart Programming
Рет қаралды 378 М.
Solve any Number Program
16:46
Simply Coding
Рет қаралды 86 М.
Count the number of Digits of a Number | Java
6:19
B Tech Computer Science
Рет қаралды 34 М.
.equals() vs. == in Java - The Real Difference
8:48
Coding with John
Рет қаралды 179 М.
Java program to check Number is Prime or Not | Learn Coding
10:17
Learn Coding
Рет қаралды 236 М.
ТАМАЕВ vs ВЕНГАЛБИ. Самая Быстрая BMW M5 vs CLS 63
1:15:39
Асхаб Тамаев
Рет қаралды 4,7 МЛН