Loading Now

kthBoring

A number is considered to be boring if:

  • it’s a positive integer;
  • it’s not prime;
  • it does not belong to the Fibonacci sequence.

Given a number k, find the kth boringnumber when counting up from 1.

Example:

  • For k = 1, the output should be kthBoring(k) = 4.

    The numbers 1, 2 and 3 belong to the Fibonacci sequence, so they are not boring. The number 4 is not prime and does not belong to the Fibonacci sequence, so it’s the 1st boringnumber.

  • For k = 2, the output should be kthBoring(k) = 6.

    The number 5 is prime, so it’s not boring, meaning that the 2nd boringnumber is 6.

Input/Output:

  • [execution time limit] 0.5 seconds 

  • [input] integer k
    1 ≤ k ≤ 2 · 105.

  • [output] integer

    The kth boring number when counting up from 1.

Post Comment

Contact