|
|
A057340
|
|
Smallest of the most frequently occurring numbers in 1-to-n multiplication cube.
|
|
4
|
|
|
1, 2, 6, 12, 12, 12, 12, 24, 72, 60, 60, 72, 72, 72, 120, 240, 240, 180, 180, 360, 360, 360, 360, 720, 720, 720, 720, 720, 720, 720, 720, 720, 720, 720, 840, 2520, 2520, 2520, 2520, 1440, 1440, 2520, 2520, 2520, 2520, 2520, 2520, 5040, 5040, 5040, 5040
(list;
graph;
refs;
listen;
history;
text;
internal format)
|
|
|
OFFSET
|
1,2
|
|
LINKS
|
|
|
EXAMPLE
|
M(n) is the array in which m(x,y,z)=x*y*z for x = 1 to n, y = 1 to n and z = 1 to n. In M(7), the most frequently occurring numbers are 12 and 24, each occurring 15 times. The smallest of these numbers is 12, so a(7) = 12.
|
|
PROG
|
(Java)
public class SmallestMultCube {
static int low, highestFrequency = 0;
static int[] counters;
public static void main(String[] args) {
int max=500;
counters = new int[max*max*max+1];
for(int outer=1; outer<=max; outer++) {
tally(outer*outer*outer, 1);
for(int middle=outer-1; middle>=1; middle--) {
tally(outer*outer*middle, 3); tally(outer*middle*middle, 3);
for(int inner=middle-1; inner>=1; inner--) {
tally(outer*middle*inner, 6); } }
System.out.println(outer+" "+low); } }
private static void tally(int number, int repeatFactor) {
counters[number] += repeatFactor;
if(counters[number] >= highestFrequency) {
if (counters[number] == highestFrequency)
if (number < low) low = number;
if (counters[number] > highestFrequency) {
highestFrequency = counters[number]; low = number; } } } }
|
|
CROSSREFS
|
|
|
KEYWORD
|
nonn
|
|
AUTHOR
|
|
|
EXTENSIONS
|
|
|
STATUS
|
approved
|
|
|
|