Question d’entretien chez Barclays

2. Coding: Find the n-th prime number

Réponse à la question d'entretien

Utilisateur anonyme

6 nov. 2018

Use primality algorithm for each integer k<=n, test if the number k is evenly divisible by 2 and 3 and then check for numbers of form 6k+-1<=sqrt(k). Complexity for each k: sqrt(k)/3 Total complexity: Sum over all k ~ O(nsqrt(n))