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 #50: Consecutive prime sum

Project Euler #50: Consecutive prime sum

Problem
Submissions
Leaderboard
Discussions

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

The prime , can be written as the sum of six consecutive primes:

This is the longest sum of consecutive primes that adds to a prime below one-hundred.

The longest sum of consecutive primes below one-thousand that adds to a prime, contains terms, and is equal to .

Which prime, , can be written as the sum of the most consecutive primes?
Note: You have to print prime as well as the length of consecutive chain whose sum is prime. If such primes are more than 1, print the least.

Input Format

The first line contains an integer , i.e., number of test cases.
Next lines will contain an integer .

Constraints


Output Format

Print the values corresponding to each test case in a new line.

Sample Input

2
100
1000

Sample Output

41 6
953 21

Author

shashank21j

Difficulty

Hard

Max Score

100

Submitted By

1814

Need Help?


View discussions
View top submissions

rate this challenge

MORE DETAILS

Download problem statement
Download sample test cases
Suggest Edits

Choose a translation


  • Blog
  • Scoring
  • Environment
  • FAQ
  • About Us
  • Support
  • Careers
  • Terms Of Service
  • Privacy Policy