ROSECODE 422
Friedman Numbers
A Friedman number is a number which can be written using all its digits exactly once and a combination of the following operations:
+ (addition)
- (subtraction)
* (multiplication)
/ (division)
^ (exponentiation)
, (concatenation) [*]
Examples:
5776 = 76^(7-5) = 76 7 5 - ^
8092 = (90^2)-8 = 90 2 ^ 8 -
11943 = (11^3-4)*9 = 11 3 ^ 4 - 9 *
16225 = ((52^2)*6)+1 = 52 2 ^ 6 * 1 +
Expressions are represented in postfix notation
Let's call the set of terms used in a decomposition, the primitive factors.
The Friedman number 1395 has two sets of primitive factors:
For we have the following decompositions:
In the range , find the Friedman number with the most primitive factors
For each primitive factors of this number, find the corresponding decompositions and give the first one in alphabetic order (in postfix notation).
(The primitive factors are sorted in lexicographic order : first by length, then by values)
Answer format : (Comma separated list for primitive factors 1)(colon)(decomposition 1)(pipe)...
Example: 2,9,16:16 9 2 ^ *|1,2,6,9:6 9 1 - 2 / ^ // in the range
[My timing : 100 sec]
[*] Concatenation can only be used to build the integers used in expressions, but not in expressions.
+ (addition)
- (subtraction)
* (multiplication)
/ (division)
^ (exponentiation)
, (concatenation) [*]
Examples:
5776 = 76^(7-5) = 76 7 5 - ^
8092 = (90^2)-8 = 90 2 ^ 8 -
11943 = (11^3-4)*9 = 11 3 ^ 4 - 9 *
16225 = ((52^2)*6)+1 = 52 2 ^ 6 * 1 +
Expressions are represented in postfix notation
Let's call the set of terms used in a decomposition, the primitive factors.
The Friedman number 1395 has two sets of primitive factors:
For we have the following decompositions:
In the range
For each primitive factors of this number, find the corresponding decompositions and give the first one in alphabetic order (in postfix notation).
(The primitive factors are sorted in lexicographic order : first by length, then by values)
Answer format : (Comma separated list for primitive factors 1)(colon)(decomposition 1)(pipe)...
Example: 2,9,16:16 9 2 ^ *|1,2,6,9:6 9 1 - 2 / ^ // in the range
[My timing : 100 sec]
[*] Concatenation can only be used to build the integers used in expressions, but not in expressions.