Question d’entretien chez Fidelity Investments

Write a Java function that prints all the prime numbers up to a specified value and explain its time complexity.