An algorithm based on Eratosthenes Sieve

  • Thread starter alejandrito
  • Start date
  • Tags
    Algorithm
In summary, the conversation discusses modifying the Eratosthenes Sieve to count the number of divisors of a given number and finding an algorithm that works efficiently for numbers up to 10000. The conversation includes various estimations and hints for solving the problem, with a focus on using the simplification of the Eratosthenes Sieve to achieve an O(n.log n) efficiency. The conversation also mentions the use of sums of reciprocals of numbers and their asymptotic behavior as useful tools for solving the problem.
  • #1
alejandrito
7
0
Modify the Eratosthenes Sieve to count the number of all divisors of the given number. Find an algorithm which for given number N <= 10000 will create a field of N numbers such that the value of the i-th element of the field is the number of all divisors of the number i for each i <= N, but the solution mustn´t be worse than O(n.log n).
I don´t have any idea how to proceed if I should satisfy the given maximal difficulty. Can anybody give me some hint? Thank you.
 
Technology news on Phys.org
  • #2
It's usually a good idea to simply try and solve the problem first, and then worry about how efficient is.

Do you know how to solve the problem with any algorithm?
 
  • #3
Ok... if I proceed according to Eratosthenes (so I start in 2 and below each multiple of 2 i make some sign and do this whith each prime p_k <= n without any simplification, finally the number of signs at i-th position will be the number of all divisors of i). This algorithm has the effecienty O(n/2 + n/3 + n/5 + ... n/p_k) where p_k is the maximal prime less or equal as n. The estimation of this could be n(SUM of 1/p_j) <= n*(number of all primes <= n) < 6n/ln(n) which results enough or not? I don´t really know and also I´ve used one very strong mathematical estimation so this seems to me very strange..I've obtained a hint that I should use the simplification of Eratosthenes Sieve that works in time O(n.log n), but I don´t know this simplification and also I cannot find it. So I think that this approach without any simplification doesn´t solve the problem. That´s what I have found about it. And also you´re right in that I´m beginner in programming. Generally I´m very confused... it´s enough or not?
 
Last edited:
  • #4
The estimation of this could be n(SUM of 1/p_j) <= n*(number of all primes <= n) < 6n/ln(n)
An estimate, not the estimate. :tongue2: And I think you dropped the "n*" -- shouldn't that be 6n²/ln(n)?

1 is a lot bigger than [itex]1/p_j[/itex], so it seems plausible that this is an overestimate. Do you know anything about sums of reciprocals of things?
 
Last edited:
  • #5
I think that the estimation established by n/8 ln n < PI(n) < 6n/ln n is correct (which results form the work of Chebyshev, he also prooved that there are better constants than 1/8 and 6 in the estimations like a previous and I really believe in it) and is is also coppied from one manual (I am not saying that everything in it must be correct but I think that this inequality is)

Do you know anything about sums of reciprocals of things? It´s very general question I may know something... but maybe I still cannot see what do you want to tell me... maybe we can estimate it using another way SUM(1/p_j) <= SUM(1/i, i:=2 to n) < log n which can be very easily prooved by the graphical approach (SUM(1/i, i:=2 to n) < INTEGRATE from 1 to N (dx / x) = log n. You think that this suffices to me?
 
  • #6
I think that the estimation established by n/8 ln n < PI(n) < 6n/ln n is correct (which results form the work of Chebyshev, he also prooved that there are better constants than 1/8 and 6 in the estimations like a previous and I really believe in it) and is is also coppied from one manual (I am not saying that everything in it must be correct but I think that this inequality is)
That I believe.

But remember that your expression was n*PI(n), and the upper bound on that would be n*(6n/ln n)


Do you know anything about sums of reciprocals of things? It´s very general question I may know something... but maybe I still cannot see what do you want to tell me... maybe we can estimate it using another way SUM(1/p_j) <= SUM(1/i, i:=2 to n) < log n which can be very easily prooved by the graphical approach (SUM(1/i, i:=2 to n) < INTEGRATE from 1 to N (dx / x) = log n. You think that this suffices to me?
It sure sounds like it proves [itex]n \sum_j 1/p_j < n \ln n[/itex]?

This particular sum: [itex]\sum_{i = 1}^n 1/i \in \Theta(\ln n)[/itex] is a good one to remember.
 
  • #7
I think that the estimation established by n/8 ln n < PI(n) < 6n/ln n is correct (which results form the work of Chebyshev, he also prooved that there are better constants than 1/8 and 6 in the estimations like a previous and I really believe in it) and is is also coppied from one manual (I am not saying that everything in it must be correct but I think that this inequality is)
That I believe.

But remember that your expression was n*PI(n), and the upper bound on that would be n*(6n/ln n)


Do you know anything about sums of reciprocals of things? It´s very general question I may know something... but maybe I still cannot see what do you want to tell me... maybe we can estimate it using another way SUM(1/p_j) <= SUM(1/i, i:=2 to n) < log n which can be very easily prooved by the graphical approach (SUM(1/i, i:=2 to n) < INTEGRATE from 1 to N (dx / x) = log n. You think that this suffices to me?
It sure sounds like it proves [itex]n \sum_j 1/p_j < n \ln n[/itex].

This particular asymptotic, [itex]\sum_{i = 1}^n 1/i \in \Theta(\ln n)[/itex], is a good one to remember.
 

1. What is an algorithm based on Eratosthenes Sieve?

An algorithm based on Eratosthenes Sieve is a method for finding all prime numbers from 2 to a given number n. It is named after the ancient Greek mathematician Eratosthenes, who first came up with this method.

2. How does the Eratosthenes Sieve algorithm work?

The algorithm works by creating a list of numbers from 2 to n and then systematically eliminating all multiples of each prime number in the list. The remaining numbers in the list after this process are the prime numbers.

3. What are the advantages of using the Eratosthenes Sieve algorithm?

One advantage is that it is relatively efficient and fast compared to other methods of finding prime numbers. It also does not require complex mathematical calculations, making it easy to implement.

4. What are the limitations of the Eratosthenes Sieve algorithm?

The main limitation is that it is only practical for finding prime numbers up to a certain limit. As the number n increases, the time and space complexity of the algorithm also increase significantly.

5. Can the Eratosthenes Sieve algorithm be used for other purposes?

Yes, this algorithm can also be adapted for other applications such as finding all the factors of a given number or checking for primality of a single number. It can also be extended to find prime numbers in a given range of numbers.

Similar threads

  • Programming and Computer Science
Replies
1
Views
1K
  • Programming and Computer Science
Replies
12
Views
1K
  • Programming and Computer Science
Replies
4
Views
10K
  • Engineering and Comp Sci Homework Help
Replies
1
Views
1K
  • Programming and Computer Science
Replies
8
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
1
Views
2K
  • Programming and Computer Science
Replies
1
Views
2K
  • Set Theory, Logic, Probability, Statistics
Replies
1
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
1
Views
986
Replies
2
Views
6K
Back
Top