Prime factorization of a number

  Рет қаралды 89,937

mycodeschool

mycodeschool

Күн бұрын

Пікірлер: 74
@pratyushpal3311
@pratyushpal3311 4 жыл бұрын
Correction.! While writing code... Store the value of n in a separate variable. Because, inside while loop, we are continuosly decreasing it's value and. And once you come out of the while loop and go up in the for loop. The value of "n" Is decremented. So, right thing to do is store value of 'n' in a separate variable. And use it for the 'for' loop. And use the actual 'n' everywhere inside the for loop.
@sagaralwani75
@sagaralwani75 3 жыл бұрын
you are wrong my friend, look at it correctly, he is right, with all respect I just want to say he is correct, look at the actual mathematics, this is what happens like = 30 = 2*3*5... the first iteration divided by 2, n becomes 15 second time it will be divided by 3 and will become 5 and at last, n will be one and when i is 6, the for-loop condition will be tested as 6 is not less than 1, it won't go inside the loop and yes we are done...
@yashsalvi5043
@yashsalvi5043 3 жыл бұрын
I'm also feeling the same, that the value for sqrt(n) should be a separate variable ! Say we're checking prime factors of 50, then at first i=2; i< √50 , Now we'll go inside of while and then N will be 25, and hence we'll come out of if loop and then the condition inside of for would be like for(i=3; i< √25 ; ....) . Hence, we'll never go to i= 5 !! . That's my POV, I may be wrong though. Can anyone help me out with this ?!
@mihaisuciu6674
@mihaisuciu6674 6 жыл бұрын
One of the best programming channel. Great job, i hope and wish that you are going to start posting videos again (I know it s a lot of work behind). Thank you Sir.
@AdityaSingh-ql9ke
@AdityaSingh-ql9ke 2 жыл бұрын
They cant. It was a 2 man show...and one of the guys died in an accident, He was the best coder in India in his time. SuryaHarshaNarayan aka humble_fool
@TheSachinAlam
@TheSachinAlam 3 жыл бұрын
This is channel is still a gem!!!!
@xanrd77
@xanrd77 5 жыл бұрын
This was exactly what I needed. Thank you!
@mycodeschool
@mycodeschool 11 жыл бұрын
Thanks Hasibul !
@dhariri
@dhariri 9 жыл бұрын
Very nicely explained, but by setting n explicitly inside the while loop you prevent the for loop from continuing to the next i. In the example of 6, the algorithm will return 2^1 instead of 2^1 and 3^1 (because n has been reduced to 2 which breaks the for loops rule that i must be less than n, which is now set as 2).
@dhariri
@dhariri 9 жыл бұрын
+David Hariri that is for traditional for loops I should say where i < n
@syedsouban9870
@syedsouban9870 6 жыл бұрын
Yes you are right David, I also observed the fault in the algorithm. The channel does not seem to reply. I guess the correct method should be i
@MohitSharma-lz1nc
@MohitSharma-lz1nc 6 жыл бұрын
No, it is correct the last if statement will check that condition.First while will reduce n = 6 to n = 6/2 = 3 and comes out .Second time for loop will terminate as Sqrt(3)
@003kazimehrabrashid4
@003kazimehrabrashid4 6 жыл бұрын
ya, i found nothing wrong with this code.
@Aniket7Tomar
@Aniket7Tomar 10 жыл бұрын
in the "worst case" while doesn't play a role and we get O(root n). How can we be sure that in all the other "non worst cases" even though while will be involved we wont get more than O(root n)? i do get it somewhat but not completely tnx
@sirtejabaskerville
@sirtejabaskerville 9 жыл бұрын
"while" loop might not play any role but the "for" loop will be running till n. So he reduced it to sqrt(n).
@enigmaamgine6827
@enigmaamgine6827 3 жыл бұрын
One of the best channel for code learning
@sagaralwani75
@sagaralwani75 3 жыл бұрын
6:07 I am fascinated and excited and I am in joy that you are going to answer my question, I am struggling to understand...
@moonvanestar
@moonvanestar 4 жыл бұрын
BRO, hablo español, pero en verdad, llevo mucho tiempo buscando un tutorial completo de este tema, para poder mejorar la complejidad en un código, y además de que tu pseudocódigo me ayudo a mejorar el mió, lo explicaste todo muy bien!, en verdad muchas gracias, tienes un nuevo suscriptor
@ahmadahmadi8398
@ahmadahmadi8398 11 жыл бұрын
thanks sir, very nice lessons ... those how want really improve thier skills will be amazed by ur vedios ... thanks but sir add up some more videos on algorithems and Java language... thanks I am also B.Sc student thanks...
@cesarjom
@cesarjom 8 жыл бұрын
correction at 9:14 ? i does NOT become greater than n (n=44) at i =12, the condition to exit loop. Rather I think the presenter meant to say i becomes greater than n / 2, which is also valid reason to exit for-loop.
@verynicehuman
@verynicehuman 8 жыл бұрын
i does become greater than n. i would be 12 and n would be 1 so obviously 12>1. The mistake you made is in the for loop. for(i=2;i
@shubhamAgrawal21
@shubhamAgrawal21 10 жыл бұрын
very nicely explained sir,but i didn't get how in the worst case the inner while loop will execute only once...
@ajoydev8876
@ajoydev8876 3 жыл бұрын
but, I have little bit a confusion that, first for(int i = 2; i
@doingsneakypeakylike
@doingsneakypeakylike 5 жыл бұрын
This channel is gold! Thank you.
@ravikhatri24
@ravikhatri24 5 жыл бұрын
Was gold, he died in a car accident
@adityashidlyali7814
@adityashidlyali7814 4 жыл бұрын
@@ravikhatri24 is it true? Bro?
@unknownman1
@unknownman1 4 жыл бұрын
@@ravikhatri24 *Idiot* , not this guy, but the co-founder of this channel died in a car accident. The voice of the guy which we hear in all videos is still alive and is working at Google.
@kushalava007
@kushalava007 2 жыл бұрын
thank you so much. Excellent explanation
@adityamore2616
@adityamore2616 4 жыл бұрын
first time I am interested in algorithms because of you, thanks.🙏
@akashbhadouria6727
@akashbhadouria6727 4 жыл бұрын
He's no more
@adityamore2616
@adityamore2616 4 жыл бұрын
@@akashbhadouria6727 what no more?
@akashbhadouria6727
@akashbhadouria6727 4 жыл бұрын
@@adityamore2616 He died ⚰in a road accident. This is what I heard and read comments on his videos. He's dead!
@adityamore2616
@adityamore2616 4 жыл бұрын
@@akashbhadouria6727 okay, RIP a good person⚰
@indiansoftwareengineer4899
@indiansoftwareengineer4899 4 жыл бұрын
​@@akashbhadouria6727 Oh bro, very bad, seriously feeling bad for him. RIP, I used to watch his channel in first/second year of university, before 4-5 years, when there were no more coding channels for algorithms.............
@Nick-oe1dq
@Nick-oe1dq 4 жыл бұрын
Hello, can someone type the coding on the left I'm finding it a bit confusing
@lomeshdaheria9960
@lomeshdaheria9960 4 жыл бұрын
Thank you 😊😊😊 for the wonderful explanation
@aziz9488
@aziz9488 9 жыл бұрын
Thanks sir but I believe that if n is prime the while loop won't execute except if i=n it will run once, is this true ?
@siddharthasharma5900
@siddharthasharma5900 6 жыл бұрын
you are right.
@devendrakumar6240
@devendrakumar6240 5 жыл бұрын
but the last if statement will print the prime no.(n)
@AdrianFI
@AdrianFI 3 жыл бұрын
thankyou very much i understand this very clearly
@kalyanitewari
@kalyanitewari 4 жыл бұрын
Thank you so very much sir, really helped a lot.
@surajpatel2308
@surajpatel2308 4 жыл бұрын
who else is watching in 2020.
@avulalakshmidevi9807
@avulalakshmidevi9807 4 жыл бұрын
Thanks for explain this lesson
@shahariarkabir210
@shahariarkabir210 7 жыл бұрын
nice explanation
@BenjiBoyOfficial
@BenjiBoyOfficial 7 жыл бұрын
Great video !
@dontony7071
@dontony7071 4 жыл бұрын
Got it bro.Thanks
@whereismycheese2089
@whereismycheese2089 5 жыл бұрын
your primeFactorization function stops when i is 6 (n is given as 44).. correct?
@ashish3944
@ashish3944 4 жыл бұрын
i think it would stop before 6....at 4...since inside the value of n is being changed by the statement n/=i; so it would affect the for loop condition.
@nikhilraj6268
@nikhilraj6268 4 жыл бұрын
@@ashish3944 I will not go till 4 , it will remain at 2 and finally get 2*2*11
@decodingmathematics9957
@decodingmathematics9957 3 жыл бұрын
@@nikhilraj6268 when i=2 exits, n would have become 11 , it will change sqrt(n) to 3, loop enters for i=3 , not divisible , now the loop breaks when i=4
@bipul2138
@bipul2138 6 жыл бұрын
nice one sir
@janvimyadventures1310
@janvimyadventures1310 3 жыл бұрын
Everyone like regional language Hindi our mother tongue But an Indian coder needs to speak English many people will be helped .
@belgacembenamira2779
@belgacembenamira2779 3 жыл бұрын
Thank you
@ShivamVerma-gq2sm
@ShivamVerma-gq2sm 3 жыл бұрын
Thankyou !
@alyaaahmed4462
@alyaaahmed4462 2 жыл бұрын
thanks soooooooooooooooooooo much
@hemelkhan1
@hemelkhan1 11 жыл бұрын
very nice
@yashasgowda1361
@yashasgowda1361 3 жыл бұрын
Me watching one day before my board practical exam
@pranjalgoyal6747
@pranjalgoyal6747 4 жыл бұрын
What a great man So sad that he died so early. Otherwise he would have been a great teacher
@AtulSingh-xt7zb
@AtulSingh-xt7zb 4 жыл бұрын
I think the one in this video is not Harsh, he is Animesh. Anyway, this has to be one of the best channels on programming so far.
@fredrickarichards8548
@fredrickarichards8548 8 жыл бұрын
ok
@manojeet_das
@manojeet_das 6 жыл бұрын
what about no. 26? square root of 26 is about 5.1 , so the value of i will never reach 13 so, it will only print 2
@suprithnarayan9894
@suprithnarayan9894 6 жыл бұрын
last if statement take care of that.
@SumitKumar-wu4cj
@SumitKumar-wu4cj 5 жыл бұрын
manojeet gawar ...
@SumitKumar-wu4cj
@SumitKumar-wu4cj 5 жыл бұрын
manojeet you are my tatti
@abdullahshahid7172
@abdullahshahid7172 7 жыл бұрын
bad
GCD using Euclid's algorithm
15:33
mycodeschool
Рет қаралды 64 М.
Factoring Quadratics WITHOUT Guessing Product & Sum
20:01
JensenMath
Рет қаралды 123 М.
How Many Balloons To Make A Store Fly?
00:22
MrBeast
Рет қаралды 96 МЛН
Finding Prime numbers - Sieve of Eratosthenes
9:54
mycodeschool
Рет қаралды 308 М.
Why 7 is Weird - Numberphile
12:03
Numberphile
Рет қаралды 1,9 МЛН
Insertion sort algorithm
14:15
mycodeschool
Рет қаралды 1,5 МЛН
What is 0 to the power of 0?
14:22
Eddie Woo
Рет қаралды 10 МЛН
Understand Calculus in 10 Minutes
21:58
TabletClass Math
Рет қаралды 8 МЛН
how to study less and get higher grades
11:16
Gohar Khan
Рет қаралды 1,2 МЛН
How many times is a sorted array rotated?
13:03
mycodeschool
Рет қаралды 172 М.
Finding all factors of a number
6:53
mycodeschool
Рет қаралды 114 М.