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 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 😊
you should include another condition if the n is less than 2, then it should also print false. this for loop should be in else part. think about all kind of test cases.
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.
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!!
@@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...
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😊
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
@@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.
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!
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.
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); }
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.
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❤️
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.
I am caught up with my work, but u just inspired me to make more videos.
@@BTechComputerScience its my pleasure ❤️
@@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 😊
@@aarulmozhinandhini1540 I will surely try
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.
So crisp and to the point explanation...Thank yoouu!
Thankyou. Fully understood. Keep posting vedios on Java. Simply easy to understand the way you teach. All is well.
Thank you so much. You simulated the logic on paper and that made me understand it better. Keep it up!
I referred so many videos for this program. After watching yours my doubt got fully solved. Thankyou so much.
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
Your channel deserves more Recognition 👍
Plz do post more videos
Hehe, thanks!
Bruh, you don’t know how many videos i watched for it, and this one is the simplest. ❤️❤️
Hehe... glad it helped!
Thankyou for explaining prime number concept in a clear manner.
Very simple approach,, tqq broo
Really the simplest explanation everrr
Honestly the best explanation ever broo
Very good and quiet ... Keep doing... 👍👍👍
May i know why did you start the for loop from 2 ? Because as per index its start from 0 so its supports to be 1 i mean for (int i=1)
Thank you so much it was really helpful. Appreciate your effort!👏
Thank you so much for clearly explaining the topic.. Please upload more videos
Super explanation to easy way of coding tq😊
you should include another condition if the n is less than 2, then it should also print false. this for loop should be in else part. think about all kind of test cases.
Thank you so much ❤ You make it look so easier....
thank you so much because of you I got the confidence to code easily :)
Coding is very simple :)
Thank you so much sir it's helping me lot and now program Is very easy to me when u explained it clearly..
Keep learning 😃
Very simple and easy tq brother
Very clear explanation thank you
Thank you very much, you explained it in detail.
Sir please make more videos on same topic like Palindrome number , angstrom number , factorial....
You explain very good ❤️❤️❤️😀
I request u to post more videos like this...thank you so much ❤
this was the best explanation
nice hand writing , like your font ..
very nice sir. it looks very easy now.
what if we take n =2 then 2%2 = 0 so will it not give output as not prime
Superb explanation sir got it very well
So many website theri use for loop( i=
Thanks man you made it clear :)
Thankyou so much now I can clearly understand how to print prime no. What's the logic behind this program ☀️💯
That's great!
Thank You Bro.. you made it really simple
Thank you so much. you explained it in a beautiful and easy way.
Thank u so much!😊
Helpful video tq sir 👍
Super bro nice teaching
beautiful answer but there are one mistake bro , if you are entered n = 1; output is true , this is wrong step
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.
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
Before for loop add one if(n
cool stuff, really cool stuff
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 .
Good work💯
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!!
So good to hear😊❤
Keep doing great👍
U are the unique one sir
I could able to understand the concept very deeply
Thank you sir very much❤️❤️❤️❤️❤️
I am glad it was helpful
Thanks.. but the output should be a little bit more specified !
I think We can't find 2 as a prime number by this program..please do check with 2
In that case we have to check (flag && n>1)i.e 2>1 then 2 is a prime number
nice explanation
Simple Explanation
Can you do programs and its output for all basic programs in java and also of different way of approaching.......
what will be the output for 1 and 2 ?
Good explanation
bro why did you used util package . Can you please explain
Bro make video for how to trace out the program !
Very very thank you sir...
What is the output if n=4 can you show
Super bro ❤️
why for loop i starts from 2? i refers to index right?
@@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...
thanks man! but the package prime; is really hitting me i dont get it right on blue j please respond fast
Thank you❣️
Bro Please do video on SQL queries plz plz
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
please explain sir
i have confusion
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😊
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
@@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.
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
Bro what happens if I give n = 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
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!
@@BTechComputerScience K Thank you
Tomorrow I have exam thank you sir for your effort🙏
Do well!
Bro screen sarriga kanipinchadam ledhu and voice vinipinchadam ledhuu broh..
but 2 is considered as a prime number the code will not be accurate here
In case of 15 is not eligible for this method
Bro your code go wrong if you input 2
Thanks 😊
bhai ye programme 2 ke liye fail ho jaega .......isme extra condition add krni pdegi
Kaisaaa woo kaisa
Sir can u please explain me kaprekar number?
why we are running it from i=2 in for loop ?
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.
@@BTechComputerScience thank you soo much sir
In.. Your code we take... 2 then.. Its show not prime.. Number but 2 is prime number... Know... Then.. What we do
Think about the logic, I know u can solve it! I just gave the basic logic for the program 😊
sir why you can not take 9
then u will took 9 it will print is a prime
but it is not a prime
It will not print 9 as prime 😊
thank you so much
great sir
Codechef says this approach is wrong
if you enter 0 or 1 it says it's a prime number
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);
}
And then put the video for sum of primenumber ina given sequence
Okay bro check n=2
what about 0 and 1
Yess if(n == 0 || n == 1){
It's not a prime }
Else
{ The vedio logic , the condition inside for loop must be n/2 }
0 and 1 ke case me fail ho jayega yeh program
Yess if(n == 0 || n == 1){
It's not a prime }
Else
{ The vedio logic , the condition inside for loop must be n/2 }
Nice explanation but video is not getting clear
Thanks and sorry about that! Maybe its a little better at higher resolution.
9 is not a prime number because it's multiple by 3, 1, 9..
I think you have not watched the video fully
I want with inheritance
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.
Please check ur program properly
Love you
What if number is 2
Since 2 is divisible by 1 and the number itself (2), it is a prime number :)
how to pass n=2 into loop?
bro 9 is not prime 1 3 9
Yes, it's not prime. What happened?
java basic
OG❤
raza sir
wow.
😜
Sir plz provide your email
🤙💫
bro have pet crows
😂😂
System.out.println("Thanks");
True coder🤘
9 is not a prime number because it's multiple by 3, 1, 9..
Sorry