Re: Working with factors of triangular numbers.
- To: mathgroup at smc.vnet.net
- Subject: [mg78557] Re: Working with factors of triangular numbers.
- From: Jean-Marc Gulliet <jeanmarc.gulliet at gmail.com>
- Date: Wed, 4 Jul 2007 05:34:48 -0400 (EDT)
- Organization: The Open University, Milton Keynes, UK
- References: <f6d4ll$hka$1@smc.vnet.net>
Diana wrote:
> Math folks,
>
> I first generate a list of triangular numbers:
>
> 1, 3, 6, 10, 15, 21, ...
>
> and then subtract one from each as:
>
> 0, 2, 5, 9, 14, 20, ...
>
> I am trying to find the smallest triangular number (minus one) which
> can be written as a product of "n" distinct factors, each factor > 1.
>
> For example:
>
> a(2) = 15, because 2*7 + 1 = 15.
> a(3) = 55, because 2*3*9 + 1 = 55.
>
> I have worked with Divisors and FactorInteger, but am getting bogged
> down with repeated terms. Can someone think of a neat trick to work
> this problem?
>
> Diana M.
Hi Diana,
To me, your requirements are crystal clear, so I may not have correctly
understood what you are trying to achieve; nevertheless, the following
function 'seek' should return the expected results. (Note that this code
is not memory efficient.)
In[1]:= T[n_Integer /; n > 0] := Binomial[n + 1, 2]
In[2]:= t = T /@ Range[30]
Out[2]= {1, 3, 6, 10, 15, 21, 28, 36, 45, 55, 66, 78, 91, 105, 120, 136,
153, 171, 190, 210, 231, 253, 276, 300, 325, 351, 378, 406, 435, 465}
In[3]:= seek[m_Integer /; m > 0, p_] :=
Module[{l = p - 1 /. 0 -> Sequence[], prod, target},
prod = (Union[Apply[Times, Subsets[Most[Rest[Divisors[#1]]], {m}],
{1}]] & ) /@ l;
target = Transpose[{l, prod}];
Select[Transpose[{l, prod}], MemberQ[#1[[2]], #1[[1]]] & ,
1] /. q_ /; Length[q] > 0 :> q[[1, 1]] + 1]
In[4]:= seek[2, t]
Out[4]= 15
In[5]:= seek[3, t]
Out[5]= 55
In[6]:= seek[4, t]
Out[6]= 253
Regards,
Jean-Marc