[Jprogramming] index of the highest number in a list

alessandro codenotti code95 at live.it
Fri Nov 30 12:00:01 UTC 2012


Solving Project Euler 69 i encountered a problem, with the following J code:

>./(>:i.10e6)%5 p: >:i.10e6

i can easily find out which is the maximum value of n/phi(n) for n<10e6, but how can i know what is the value of n?

Or, generalizing the question, given a list N how can i know the index of the highest element?
I'm really a beginner in J so i guess the solution to my problem is very very easy but i cannot find it...
Thank in advice to everyone that will help me!

p.s.
here is the PE 69 i referred to:

Euler's Totient function, φ(n) [sometimes called the phi function], is used to determine the number of numbers less than n which are relatively prime to n. For example, as 1, 2, 4, 5, 7, and 8, are all less than nine and relatively prime to nine, φ(9)=6.

It can be seen that n=6 produces a maximum n/φ(n) for n  10.
Find the value of n  1,000,000 for which n/φ(n) is a maximum.


 		 	   		  


More information about the Programming mailing list