Problem 070
Forum rules
As your posts will be visible to the general public you are requested to be thoughtful in not posting anything that might explicitly give away how to solve a particular problem.
This forum is NOT meant to discuss solution methods for a problem.
See also the topics:
Don't post any spoilers
Comments, questions and clarifications about PE problems.
As your posts will be visible to the general public you are requested to be thoughtful in not posting anything that might explicitly give away how to solve a particular problem.
This forum is NOT meant to discuss solution methods for a problem.
In particular don't post any code fragments or results.
Don't start begging others to give partial answers to problems
Don't ask for hints how to solve a problem
Don't start a new topic for a problem if there already exists one
Don't start begging others to give partial answers to problems
Don't ask for hints how to solve a problem
Don't start a new topic for a problem if there already exists one
See also the topics:
Don't post any spoilers
Comments, questions and clarifications about PE problems.
- Francky
- Posts: 90
- Joined: Sat May 07, 2011 3:49 pm
- Location: South of France
Re: Problem 070
For limit=10^7, I got it after 19ms of nature* Python.
Obviously I don't presuppose any bound. Interested ?
(* no compilation, no psyco, nothing, basicaly interpreted)
For limit=10^13, 66ms (+1s for pr..), ans=9997908420679
Obviously I don't presuppose any bound. Interested ?
(* no compilation, no psyco, nothing, basicaly interpreted)
For limit=10^13, 66ms (+1s for pr..), ans=9997908420679
Entia non sunt multiplicanda praeter necessitatem-
jfren484
- Posts: 2
- Joined: Thu Aug 11, 2011 5:17 pm
Re: Problem 070
I didn't see any posts here or in the problem solution forum with a response to several statements that the answer should be n = 1. The reason I disagree with that is because 1 is not a permutation of 1. Just as 123 is not a permutation of 123 - 123 IS 123. The term permutation implies reordering somehow, and the order of digits in 1 or 123 in my example did not change, therefore any number is not a permutation of itself.
-
thundre
- Posts: 356
- Joined: Sun Mar 27, 2011 10:01 am
Re: Problem 070
The identity permutation is still a permutation, I think. Otherwise the number of permutations of 4 distinct digits would be 4!-1.jfren484 wrote:I didn't see any posts here or in the problem solution forum with a response to several statements that the answer should be n = 1. The reason I disagree with that is because 1 is not a permutation of 1. Just as 123 is not a permutation of 123 - 123 IS 123. The term permutation implies reordering somehow, and the order of digits in 1 or 123 in my example did not change, therefore any number is not a permutation of itself.
The reason n=1 is incorrect is that the problem statement specifies 1 < n < 107.

-
skoczian
- Posts: 28
- Joined: Sat May 25, 2013 4:43 pm
Re: Problem 070
"Find the value of n, 1 < n < 10^7, for which φ(n) is a permutation of n and the ratio n/φ(n) produces a minimum." How about values of n with repeated digits, would they be regarded as correct solutions? According to Wikipedia those are multiset permutations. I've searched some other problem clarification threads and found problems where multiset permutations are clearly allowed, but I don't find any general statement and the example has no repeated digits.
- sjhillier
- Administrator
- Posts: 561
- Joined: Sun Aug 17, 2014 4:59 pm
- Location: Birmingham, UK
- Contact:
Re: Problem 070
Yes, they are allowed. Just because they can be regarded as 'multiset permutations' doesn't mean they aren't also permutations.skoczian wrote: Sun Mar 19, 2017 11:32 am "How about values of n with repeated digits, would they be regarded as correct solutions?
-
pri_gua
Re: Problem 070
Could we change the definition of totient given in this problem definition? This problem defined phi(1) == 1, while for the standard or most widely used definition of phi, we have phi(1) == 0.
NOTE: phi(n) is usually defined to be the number of numbers in range [1, n - 1] that are co-prime to n, in this problem we redefined phi(n) to be the number of numbers in range [1, n] that are co-prime to n. This is not the standard definition, and might create an off-by-one error in the solution to problem 072, if we use a totient sieve. Since, phi(1) shows up as 1, instead of 0.
NOTE: phi(n) is usually defined to be the number of numbers in range [1, n - 1] that are co-prime to n, in this problem we redefined phi(n) to be the number of numbers in range [1, n] that are co-prime to n. This is not the standard definition, and might create an off-by-one error in the solution to problem 072, if we use a totient sieve. Since, phi(1) shows up as 1, instead of 0.
- jaap
- Posts: 588
- Joined: Tue Mar 25, 2008 3:57 pm
- Contact:
Re: Problem 070
Actually phi(n) really is usually defined to be the number of numbers in range [1, n] that are co-prime to n. That n itself is included in the range makes no difference in most cases since n is not coprime to n when n>1, but it does make a difference when n=1, since 1 is coprime to 1.pri_gua wrote: Thu Mar 23, 2023 6:51 am Could we change the definition of totient given in this problem definition? This problem defined phi(1) == 1, while for the standard or most widely used definition of phi, we have phi(1) == 0.
NOTE: phi(n) is usually defined to be the number of numbers in range [1, n - 1] that are co-prime to n, in this problem we redefined phi(n) to be the number of numbers in range [1, n] that are co-prime to n. This is not the standard definition, and might create an off-by-one error in the solution to problem 072, if we use a totient sieve. Since, phi(1) shows up as 1, instead of 0.
This seems arbitrary, but there is a very good reason that we want phi(1)=1. We want phi to be a multiplicative function, i.e. phi(mn)=phi(m)phi(n) when gcd(m,n)=1. Setting m=1 shows that we must have phi(1)=1 to make this work. You could also define phi(n) in terms of the prime factorisation of n, and in that case phi(1) would be the empty product, which is 1 and not 0.
-
pri_gua
Re: Problem 070
It seems like the standard definition of phi(n) is: For n >= 1, let phi(n) denote the number of positive integers not exceeding n that are relatively prime to n. (Elementary Number Theory, 7th Edition, David Burton).
Then, we should change the definition of phi in Problem 69 (View Problem)
I was going for a solution like this to Problem 72:
Then, we should change the definition of phi in Problem 69 (View Problem)
I was going for a solution like this to Problem 72:
Code: Select all
Python 3.9.16 (feeb267ead3e6771d3f2f49b83e1894839f64fb7, Dec 29 2022, 14:23:21)
[PyPy 7.3.11 with GCC 10.2.1 20210130 (Red Hat 10.2.1-11)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>> import util as U
>>>> a = 1000000
>>>> b = U.totientSieve(a)
>>>> c = SomeFunction(b) #### This would have been enough if phi(1) == 0.
>>>> YetAnotherFunction(c, SomeOtherFunction(b[0], b[1])) #### Now, we have to make this adjustment.
- hk
- Administrator
- Posts: 12831
- Joined: Sun Mar 26, 2006 10:34 am
- Location: Haren, Netherlands
Re: Problem 070
The text of Problem 69 (View Problem) reads now:
I hope this satisfies you.
Euler's Totient Function $\phi(n)$ [sometimes called the phi function], is defined as the number of positive integers not exceeding $n$ which are relatively prime to $n$. etc..
I hope this satisfies you.

War ruins the life and health of untold numbers of innocent children.
-
pri_gua
-
shaiephraim
- Posts: 8
- Joined: Mon Apr 29, 2024 8:26 pm
Problem 70
I think n=2 is a valid correct answer(phi(n)=2, they are permutation of each other so the ratio is 1), which is not what the author probably meant, please fix 
- SAG145
- Posts: 41
- Joined: Thu Apr 11, 2024 10:25 pm
-
skoczian
- Posts: 28
- Joined: Sat May 25, 2013 4:43 pm
Re: Problem 70
Sorry to be rather late, but did you look at the post by jaap, four entries above yours?shaiephraim wrote: Mon Oct 14, 2024 10:42 pm I think n=2 is a valid correct answer(phi(n)=2, they are permutation of each other so the ratio is 1), which is not what the author probably meant, please fix![]()
-
shaiephraim
- Posts: 8
- Joined: Mon Apr 29, 2024 8:26 pm
Re: Problem 70
No, I opened a new thread(newbie) and the admin merged itskoczian wrote: Wed Dec 11, 2024 3:55 pmSorry to be rather late, but did you look at the post by jaap, four entries above yours?shaiephraim wrote: Mon Oct 14, 2024 10:42 pm I think n=2 is a valid correct answer(phi(n)=2, they are permutation of each other so the ratio is 1), which is not what the author probably meant, please fix![]()

