Sieve of Eratosthenes | Journey into cryptography | Computer Science | Khan Academy

  Рет қаралды 130,750

Khan Academy Labs

Khan Academy Labs

Күн бұрын

Пікірлер: 51
@Dimension5Productions
@Dimension5Productions 4 жыл бұрын
I just did this up to 100k. I started at the start of quarantine.
@learningandgamingwithsaach8413
@learningandgamingwithsaach8413 4 жыл бұрын
Yeh
@christosbinos8467
@christosbinos8467 2 жыл бұрын
I was surprised that I could use javascript to compute up to 10m almost instantly.
@Dimension5Productions
@Dimension5Productions 2 жыл бұрын
@@christosbinos8467 Yeah I did up to a billion on python
@hil449
@hil449 2 жыл бұрын
@@christosbinos8467 ofc, the standard sieve runs in O(n * log(log(n))), thats extremely fast, in c++ you'de be able to calculate up to 10^9 in one second
@ryanventurino3578
@ryanventurino3578 4 жыл бұрын
Wonderful. Clear explanation, I liked the brief background for context, and the description was helpful and the perfect level of detail. Thank you.
@aadil4236
@aadil4236 Жыл бұрын
What a beautiful thing!!! If this is not enlightenment I don't know what is.
@DavidaThatch
@DavidaThatch 2 жыл бұрын
This was a perfect explanation, thank you!!
@Silberdragon1
@Silberdragon1 Жыл бұрын
Good Video. I forgot how it worked but you reminded me again. Thanks a lot!
@Ali_Emran
@Ali_Emran 4 жыл бұрын
WOW I UNDERSTAND EVERYTHING
@IshraqTanvir
@IshraqTanvir Ай бұрын
Love y'all ! just wow ...
@attilatoth1396
@attilatoth1396 7 жыл бұрын
Thanks!
@satishkumarsingh7354
@satishkumarsingh7354 8 күн бұрын
Number in this sives use to repeat. Is it possible to avoid repeat?
@lycan2494
@lycan2494 5 жыл бұрын
great video..
@ulti72
@ulti72 6 жыл бұрын
can you explain its complexity
@FilipeSilva1
@FilipeSilva1 3 жыл бұрын
O(sqrt(n))
@fovibhaassrivastava4951
@fovibhaassrivastava4951 Жыл бұрын
O(n log(log(n)))
@Wahee1
@Wahee1 7 жыл бұрын
0:10
@avoriginal9342
@avoriginal9342 6 ай бұрын
The pseudocode I’m failing to understand, so from 2 till sqrt of n if a is unmarked then a is prime, 2 will be unmarked, which makes it price, now for all multiples of 2, 4-6-8 etc are marked as composite, then 3 and starting from 9 to n, so at what point do we check for example 79 if we are only checking from 2 until sqrt(n), if we picked n=100 then we’d only check until 10, so what about all the number after 10 that are not marked as composite, and nowhere does it say we are checking them
@hansangjung6063
@hansangjung6063 4 жыл бұрын
Thank you.
@maxfromukraine1630
@maxfromukraine1630 2 жыл бұрын
What does he mean by "unmarked"?
@fovibhaassrivastava4951
@fovibhaassrivastava4951 Жыл бұрын
In code, it would mean an array of booleans where all values are set to true. Each time we find a composite, we mark it by changing its value to false.
@aelng1681
@aelng1681 2 жыл бұрын
super cool
@AbhishekVerma-zt7nu
@AbhishekVerma-zt7nu 4 жыл бұрын
Why start at n^2 ?
@aydc6740
@aydc6740 2 жыл бұрын
you won’t find any primes under n (the point of the sieve) by starting at n^2.
@moonman239
@moonman239 2 жыл бұрын
I wonder about something. Would it be faster to check if n is prime if, instead of listing all the primes, we calculated the row and column on which the number would lie and then used that information to check if the number is prime? For example, 27 is on row 3 column 7 (or, row 2 column 6 if you're doing zero-based indexing) What if we tried using that information to decide if 27 is prime?
@yajaman
@yajaman Жыл бұрын
If the information about whether a prime is encoded in its row and column value, you would be able to solve the twin prime conjecture
@thelast2233
@thelast2233 3 жыл бұрын
what is the range of long in java
@peiceofcheese87
@peiceofcheese87 2 жыл бұрын
From -2^63 to (2^63)-1
@thelast2233
@thelast2233 2 жыл бұрын
@@peiceofcheese87 one more question that i really stuck right now also when I see problem there is constrian like 10 ^5 and I count with t if required I know big o and I know how o(n^2) work like two loops n times goes and more on it 1 st problem is 10 ^5 means this range 100000 but we have interger range 2^63 second is when I saw constarin I got idea that I need long for 10^16 but how can I know this time bruteforce works as begginer my code will very length and many time miss edge case and so on so what should i do? Do I need to see any video or how do I practice also is akrbra bazzi formula helps
@yafethtb
@yafethtb 3 жыл бұрын
Sorry if this is a noob question. Why it must use square root of n? Why square root?
@file4318
@file4318 2 жыл бұрын
Because factors come in pairs. Take for example 16. One pair would be 1, 16... another 2, 8... 4, 4... notice they intesect on the square root (4*4=16). This means a factor cannot be above the square without having a factor pair below it. And therefore if there is no factors below the square root there can be none above either
@the_m_original
@the_m_original Жыл бұрын
suppose n is the maximum number you use to get primes. (primes up to n, suppose its 100) and p is the unmarked number you are using to mark out multiples at p = 2, you use the square of that number (2^2 = 4) to get the starting point for multiples of p. then you repeat, as explained here, to look for unmarked numbers (p = 3, p^2 = 9, so start the multiples counter at number 9.) then, as ALSO explained here, once p reaches 11 and n is 100, the square of p will be larger than n, which we dont want, so we stop, right where p is nearby the square root of n or 100, which is 10.
@bharathiDevi001
@bharathiDevi001 5 жыл бұрын
Here is the Program code: kzbin.info/www/bejne/qamWdKpnab2NpcU
@michaelfortanely5715
@michaelfortanely5715 4 жыл бұрын
based
@Progamer-wt9ir
@Progamer-wt9ir 4 жыл бұрын
Just see Dream yt
@waffles_1823
@waffles_1823 3 жыл бұрын
65 is composite
@pablocarames3261
@pablocarames3261 6 жыл бұрын
Holaaaaaa
@sarlarnsulonundedesi5913
@sarlarnsulonundedesi5913 3 жыл бұрын
hi from leetcode :D
@cait1yn_
@cait1yn_ 5 жыл бұрын
Thanks i needed to cheat on my homework cause its 10 pm RN so yea THANK YA
@HiteshLadla
@HiteshLadla 4 жыл бұрын
Why would you cheat
@Progamer-wt9ir
@Progamer-wt9ir 4 жыл бұрын
Lol
@0_-
@0_- 5 жыл бұрын
I made a python program with this and can you tell me if this is the same? (Ask me for the code)
@raresaturn
@raresaturn Жыл бұрын
65 is not prime
@marieconpacuribot2718
@marieconpacuribot2718 3 жыл бұрын
Why is it a bit confusing
@Mylok_
@Mylok_ 6 жыл бұрын
oaaaaaaaaaaaaaa
@Progamer-wt9ir
@Progamer-wt9ir 4 жыл бұрын
Lol imagine top comment being with 5 likes
@darquenite
@darquenite 5 жыл бұрын
Com-Paw-sit. Not compuhzit. So cringey.
Finding Primes in Python with the Sieve of Eratosthenes
6:51
To Brawl AND BEYOND!
00:51
Brawl Stars
Рет қаралды 17 МЛН
coco在求救? #小丑 #天使 #shorts
00:29
好人小丑
Рет қаралды 120 МЛН
UFC 310 : Рахмонов VS Мачадо Гэрри
05:00
Setanta Sports UFC
Рет қаралды 1,2 МЛН
Cheerleader Transformation That Left Everyone Speechless! #shorts
00:27
Fabiosa Best Lifehacks
Рет қаралды 16 МЛН
L6. Sieve of Eratosthenes | Maths Playlist
18:27
take U forward
Рет қаралды 66 М.
Finding Prime numbers - Sieve of Eratosthenes
9:54
mycodeschool
Рет қаралды 308 М.
The Sieve of Eratosthenes
4:52
Eddie Woo
Рет қаралды 39 М.
Sieve of Eratosthenes ( Algorithm for prime numbers)
4:49
Vivekanand Khyade - Algorithm Every Day
Рет қаралды 98 М.
Prime Numbers - Sieve of Eratosthenes
5:31
Region 10 ESC
Рет қаралды 860 М.
Pseudorandom number generators | Computer Science | Khan Academy
6:41
Khan Academy Labs
Рет қаралды 352 М.
To Brawl AND BEYOND!
00:51
Brawl Stars
Рет қаралды 17 МЛН