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
  • Practice
  • Certification
  • Compete
  • Career Fair
  • Hiring developers?
  1. All Contests
  2. ProjectEuler+
  3. Project Euler #41: Pandigital prime

Project Euler #41: Pandigital prime

Problem
Submissions
Leaderboard
Discussions

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

We shall say that an -digit number is pandigital if it makes use of all the digits 1 to exactly once. For example, is a -digit pandigital and is also prime.

What is the largest -digit pandigital prime ? If there is none, print -1

Input Format

First line contains that denotes the number of test cases. This is followed by lines, each containing an integer, .

Constraints


Output Format

Print the required answer for each test case.

Sample Input

2
100
10000

Sample Output

-1
4231

Author

shashank21j

Difficulty

Easy

Max Score

100

Submitted By

1650

Need Help?


View discussions
View top submissions

rate this challenge

MORE DETAILS

Download problem statement
Download sample test cases
Suggest Edits

Choose a translation


  • Contest Calendar
  • Blog
  • Scoring
  • Environment
  • FAQ
  • About Us
  • Support
  • Careers
  • Terms Of Service
  • Privacy Policy
  • Request a Feature