Group Abstract Group Abstract

Message Boards Message Boards

0
|
10.2K Views
|
3 Replies
|
0 Total Likes
View groups...
Share
Share this post:

Help refactoring and optimizing. Highlighting "highly composite" numbers.

POSTED BY: Christopher Fox
3 Replies
Posted 10 years ago

Hello Christopher,

this is my proposal: first generate a list holding n, Divisors of n and the Length of the list of divisors. Then you do a postprocessing (here executed by f1 and f2) and mark the "highly composite" numbers with a label (here "Red").

tab1 = Table[{n, Divisors[n], Length[Divisors[n]]}, {n, 1, 50}];
f1[{x_, max_}] := If[x[[3]] > max, {x, x[[3]], Red}, {x, max, White}]
f2[x_] := {y, max, color} = f1[{x, max}]
max = 0;
tab3 = Map[f2[#] &, tab1];
TableForm[tab3, TableDepth -> 2, 
 TableHeadings -> {None, {"n", "Divisors", "Len", "Color"}}]`
POSTED BY: Michael Helmle
POSTED BY: Christopher Fox
Posted 10 years ago
POSTED BY: Luis Ledesma
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard