Post Reply 
Triangular number AND sum of first m factorials
01-09-2018, 04:31 PM
Post: #1
Triangular number AND sum of first m factorials
153 (my favorite number) is both a triangular number (the sum of the integers 1 through \(n\); in this case \(n=17\)) as well as the sum of the factorials \(1!\) through \(m!\) (in this case \(m=5\)).

The first three natural numbers which have both of those properties are 1, 3 (both trivial) and 153. Find the next number in this sequence. For extra credit, find the mathematical relationship between \(n\) and \(m\) for all members of this sequence (which apparently is not yet in OEIS).

<0|ɸ|0>
-Joe-
Visit this user's website Find all posts by this user
Quote this message in a reply
01-09-2018, 08:53 PM (This post was last modified: 01-09-2018 10:58 PM by Gerson W. Barbosa.)
Post: #2
RE: Triangular number AND sum of first m factorials

001 LBL A
002 DEC X
003 ENTER
004 INC X
005 LBL 00
006 INC X
007 RCL* Y
008 DSE Y
009 GTO 00
010 PSE 10
011 STO+ X
012 +/-
013 1
014 ENTER
015 ENTER
016 R/\
017 SLVQ
018 X<>Y
019 FP
020 PSE 10
021 RCL L
022 RTN

2 A -> 3 -> 0 -> 2
5 A -> 153 -> 0 -> 17



The next m should be greater than 31, but I can’t find it using the wp34s, at least not with help of this simple program…

Edited to fix a typo pointed out by Dieter below.
Find all posts by this user
Quote this message in a reply
01-09-2018, 10:16 PM
Post: #3
RE: Triangular number AND sum of first m factorials
(01-09-2018 04:31 PM)Joe Horn Wrote:  153 (my favorite number) is both a triangular number (the sum of the integers 1 through \(n\); in this case \(n=17\)) as well as the sum of the factorials \(1!\) through \(m!\) (in this case \(m=5\))

It's also a narcissistic number:

153 = 1^3 + 5^3 + 3^3

V.
.

  
All My Articles & other Materials here:  Valentin Albillo's HP Collection
 
Visit this user's website Find all posts by this user
Quote this message in a reply
01-09-2018, 10:19 PM
Post: #4
RE: Triangular number AND sum of first m factorials
(01-09-2018 08:53 PM)Gerson W. Barbosa Wrote:  001 LBL A
002 DEC X
003 ENTER
004 INC C

?!? – increment register C ?
Is this possibly supposed to mean INC X ?

(01-09-2018 08:53 PM)Gerson W. Barbosa Wrote:  005 LBL 00
006 INX X

Ah, here is the missing X from line 004, and the "C" from there goes here. ;-)

Dieter
Find all posts by this user
Quote this message in a reply
01-09-2018, 11:00 PM
Post: #5
RE: Triangular number AND sum of first m factorials
(01-09-2018 10:19 PM)Dieter Wrote:  Ah, here is the missing X from line 004, and the "C" from there goes here. ;-)

:-)

Duly swapped. Thanks!

Gerson.
Find all posts by this user
Quote this message in a reply
01-09-2018, 11:10 PM
Post: #6
RE: Triangular number AND sum of first m factorials
A quick test of sums of factorials up to 69! finds no triangle numbers larger than 153. If one does exist, it has to have well over 100 digits. I may try later on the emulator.

John
Find all posts by this user
Quote this message in a reply
01-10-2018, 04:03 AM
Post: #7
RE: Triangular number AND sum of first m factorials
Tn&Sf:

« { } 3 ROT
FOR n n Sfac 8 * 1 + ISPF? { √ 1 - 2 / + n I→R + } { DROP } IFTE
NEXT
»

Sfac:

« DUP 1 - 2
FOR m 1 + m * -1
STEP 1 +
»

ISPF?

« 1
»

7 Tn&Sf ->

{ '(√73-1)/2' 3. '(√265-1)/2' 4. 17 5. '(√6985-1)/2' 6. '(√47305-1)/2' 7. }



49G or 50g in exact mode

ISPF? (IsPerfectSquare?) has yet to be implemented. It should return 1 when the argument is a perfect square and 0 otherwise. Then the output would be a list of n and m pairs, separated by dots. Just in case someone wants to try.
Find all posts by this user
Quote this message in a reply
01-10-2018, 04:58 AM
Post: #8
RE: Triangular number AND sum of first m factorials
(01-10-2018 04:03 AM)Gerson W. Barbosa Wrote:  ISPF? (IsPerfectSquare?) has yet to be implemented. It should return 1 when the argument is a perfect square and 0 otherwise.

The HP 50g LongFloat library contains a function like the one you're looking for. It's called ZSqrt, and it returns IP(sqrt(x)) to level 2, and a 0 or 1 to level 1, with 1 meaning that x was a perfect square. It works on integers of any length.

Gerald H also posted a program HERE which seems to do essentially the same thing. It returns IP(sqrt(x)) to level 2 of the stack, and on level 1 it leaves a SysRPL TRUE if x was a perfect square, otherwise a FALSE. That's the same idea as HP's FPTR2 ^ZSQRT, but Gerald's program is more accurate; see Gerald's posting for evidence of HP's function's inaccuracy.

BTW, LongFloat's ZSqrt function gets the same result as Gerald's program when given the example in Gerald's posting, so I surmise that ZSqrt is trustworthy.

<0|ɸ|0>
-Joe-
Visit this user's website Find all posts by this user
Quote this message in a reply
01-10-2018, 06:35 AM (This post was last modified: 01-10-2018 10:59 AM by Paul Dale.)
Post: #9
RE: Triangular number AND sum of first m factorials
I've got a proof that there are only three such numbers.

Consider the last pair of digits in \( \sum_1^n i! \), from n=9 onwards these never change because subsequent factorial terms will always have a factor of 100 present. These digits are '13'.

Note that n is triangular iff 8n+1 is a perfect square. For the sum of factorials to be triangular, the last two digits must therefore be '05'. Checking all possibilities shows that there are no square numbers that end '05'.

Thus, numbers of the desired form must have n < 9. Checking all cases reveals that only 1, 3 and 153 have the desired properties.


Pauli
Find all posts by this user
Quote this message in a reply
01-11-2018, 03:01 AM
Post: #10
RE: Triangular number AND sum of first m factorials
Paul: Now THAT is beautiful! Thank you! I can stop my futile hunt now. Big Grin

<0|ɸ|0>
-Joe-
Visit this user's website Find all posts by this user
Quote this message in a reply
01-11-2018, 10:21 AM
Post: #11
RE: Triangular number AND sum of first m factorials
Thanks Smile Don't let my proof stop your hunt, you'll be able to wile away many hours looking...

I hadn't realised that all square numbers that end in '5' actually end in '25'. I must have seen this before but never noticed or remembered it.


Pauli
Find all posts by this user
Quote this message in a reply
01-11-2018, 02:22 PM
Post: #12
RE: Triangular number AND sum of first m factorials
A really great thread Joe et. al. Thank you all.

John
Find all posts by this user
Quote this message in a reply
01-11-2018, 06:29 PM (This post was last modified: 01-11-2018 06:31 PM by Gerson W. Barbosa.)
Post: #13
RE: Triangular number AND sum of first m factorials
(01-11-2018 10:21 AM)Paul Dale Wrote:  Don't let my proof stop your hunt, you'll be able to wile away many hours looking...

At least I can do it a little more efficiently now :-)


100

« { } SWAP 0 1 ROT 1 SWAP
  FOR m m * SWAP OVER + ROT 
     OVER 8 * 1 + ZSqrt 
      { 1 - 2 / + m I→R + } 
      { DROP } 
     IFTE 
     SWAP ROT
  NEXT 
  DROP2 
»

EVAL

-->    { 1 1. 2 2. 17 5. }
(about 17 seconds on the real 50g)

ZSqrt from the LongFloat Library

Yes, that's a consequence of the ever growing number of trailing zeros in factorials and the properties of perfect squares.


Gerson.
Find all posts by this user
Quote this message in a reply
01-11-2018, 10:30 PM
Post: #14
RE: Triangular number AND sum of first m factorials
(01-11-2018 10:21 AM)Paul Dale Wrote:  Thanks Smile Don't let my proof stop your hunt, you'll be able to wile away many hours looking...

I hadn't realised that all square numbers that end in '5' actually end in '25'. I must have seen this before but never noticed or remembered it.


Pauli

I figured it was hopeless since I tested all sums of factorials up to 1000 (over 2500 digits) with no triangle numbers found. Took almost 20 min. on the emulator.

An interesting and educational thread indeed!

John
Find all posts by this user
Quote this message in a reply
01-11-2018, 10:43 PM
Post: #15
RE: Triangular number AND sum of first m factorials
(01-11-2018 06:29 PM)Gerson W. Barbosa Wrote:  Yes, that's a consequence of the ever growing number of trailing zeros in factorials and the properties of perfect squares.


Gerson.

Note, however, that due to the first four numbers, all of the sums of factorials end in 3.
Find all posts by this user
Quote this message in a reply
Post Reply 




User(s) browsing this thread: 1 Guest(s)