NDIVPHI - N DIV PHI_N


Given an integer N <= 1040 find the smallest m <= N such that m/phi(m) is maximum.

Input

N1
N2
.
.
.
N20

Output

m1
m2
.
.
.
m20

Example

Input:
10
.
.
Output:
6
.
.

hide comments
sheldont: 2017-06-25 11:49:47

cakewalk with python..

invincible_rm: 2016-06-26 13:29:49

Awesome !!
Just Take a deep breathe n think a strategy to procede
Its cousin can be found here: https://projecteuler.net/problem=70

Ayush Agarwal: 2014-09-28 18:31:20

python is awesome

Bharath Reddy: 2014-09-24 05:40:08

Take care of the case when n = 1

saket diwakar: 2013-01-26 00:45:13

python is awesome....:)

Samuel Shen: 2012-06-03 13:10:03

i have checked everything...its giving me correct answers for all n.....and time limit is also within 1 sec....even then TLE.....anyone plz help....

bashrc is back: 2011-06-30 16:03:13

haskell friendly problem
:)

Gurpreet Singh: 2011-01-22 10:25:44

Finally done!!!!
Lots of silly mistakes....
I considered 91 as prime .... :( and there were others tooo

Last edit: 2011-01-22 17:49:08
sudipto das: 2010-10-09 22:31:25

Range is small enough...........
I use linear search instead of binary search...........

Frank Rafael Arteaga: 2010-04-24 12:47:29

Ravi, the data test is right. In your code:

if n == 1:
print '1'
continue

and T? you are reading more lines than 20 ;)


Added by:Frank Rafael Arteaga
Date:2010-04-22
Time limit:0.142s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: NODEJS OBJC PERL6 SQLITE VB.NET
Resource:ProjectEuler