Data Structures & AlgorithmsVery hardGATE CS · ICPC regional
How many integers x in [1, 1000] have exactly 4 positive divisors?
- A. 292
- B. 293
- C. 294
- D. 296
Correct answer: A. 292
Numbers with exactly four divisors are of the form p^3 or p*q for distinct primes p and q. Counting these forms gives the total without listing divisors for each x.
Practise more Arrays, Strings, Linked Lists, Stacks, Queues and Hashing questionsArrays, Strings, Linked Lists, Stacks, Queues and Hashing: notes and key points
More Arrays, Strings, Linked Lists, Stacks, Queues and Hashing questions
- How many integers n with 1 <= n <= 200 have exactly 6 trailing zeros in n! (written in base 10)?
- What is the sum of all integers in [1, 100] whose digit sum is prime?
- A snail climbs a well of height 10 metres. Each day it climbs 3 metres; each night it slides back 2 metres. It stops when it first reaches…
- Starting at n = 7, repeat: if n is even replace n by n/2, otherwise replace n by 3n + 1. How many steps are needed to reach 1?
- What is the total number of comparisons made by insertion sort on the array [3, 1, 4, 1, 5] (each test of a[j-1] > a[j] counts as one…
- An array has values [1, 1, 1, 2, 2, 3, 4, 4, 4, 4, 5]. Every value that occurs more than twice is removed entirely. How many elements…