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 #146: Investigating a Prime Pattern

Project Euler #146: Investigating a Prime Pattern

Problem
Submissions
Leaderboard
Discussions

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

The smallest positive integer for which the numbers , , , , , and are consecutive primes is . The sum of all such integers below one-million is .

What is the sum of all integers below such that , , , , , are consecutive primes?

Input Format

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

The first line of each test case contains a single integer, . The second line contains six space-separated integers .

Constraints




Output Format

For each test case, output one line containing a single integer, the answer for that test case.

Sample Input

3
10
1 3 7 9 13 27
11
1 3 7 9 13 27
1000000
1 3 7 9 13 27

Sample Output

0
10
1242490

Explanation

As mentioned in the problem statement, the first such is , so there must be no s below . Thus, the answer for the first test case is .

The third test case is mentioned in the problem statement.

Author

kevinsogo

Difficulty

Easy

Max Score

100

Submitted By

340

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
  • Request a Feature