We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
  • Hackerrank Home
  • Prepare
    NEW
  • Certify
  • Compete
  • Career Fair
  • Hiring developers?
  1. All Contests
  2. ProjectEuler+
  3. Project Euler #123: Prime square remainders

Project Euler #123: Prime square remainders

Problem
Submissions
Leaderboard
Discussions

This problem is a programming version of Problem 123 from projecteuler.net

Let be the th prime: , and let be the remainder when is divided by .

For example, when , and .

The least value of for which the remainder first exceeds is .

Find the least value of for which the remainder first exceeds .

Input Format

The first line of input contains , the number of test cases.

Each test case consists of a single line containing a single integer, .

Constraints


Output Format

For each test case, output a single line containing a single integer, the requested answer.

Sample Input

1
100

Sample Output

5

Explanation

As noted above, the first for which the remainder exceeds is . The remainder when is , which definitely exceeds . You may easily check that the remainder doesn't exceed when .

Author

kevinsogo

Difficulty

Easy

Max Score

100

Submitted By

719

Need Help?


View discussions
View top submissions

rate this challenge

MORE DETAILS

Download problem statement
Download sample test cases
Suggest Edits
  • Blog
  • Scoring
  • Environment
  • FAQ
  • About Us
  • Support
  • Careers
  • Terms Of Service
  • Privacy Policy