[go: up one dir, main page]

login
Revision History for A356288 (Bold, blue-underlined text is an addition; faded, red-underlined text is a deletion.)

Showing entries 1-10 | older changes
Sum of numbers in n-th upward diagonal of triangle the sum of {1; 2,3; 4,5,6; 7,8,9,10; ...} and {1; 2,3; 3,4,5; 4,5,6,7; ...}.
(history; published version)
#31 by N. J. A. Sloane at Wed Oct 05 04:55:02 EDT 2022
STATUS

proposed

approved

#30 by Stefano Spezia at Fri Aug 19 09:42:55 EDT 2022
STATUS

editing

proposed

#29 by Stefano Spezia at Fri Aug 19 09:42:04 EDT 2022
LINKS

<a href="/index/Rec#order_07">Index entries for linear recurrences with constant coefficients</a>, signature (1,3,-3,-3,3,1,-1).

FORMULA

G.f.: x*(2 + 2*x + 3*x^2 + x^3 - x^4)/((1 - x)^4*(1 + x)^3). - Stefano Spezia, Aug 19 2022

KEYWORD

nonn,easy,changed

STATUS

proposed

editing

#28 by Torlach Rush at Thu Aug 18 19:12:58 EDT 2022
STATUS

editing

proposed

#27 by Torlach Rush at Thu Aug 18 19:05:12 EDT 2022
PROG

import math

def a(n): return (n * math.ceil((n + n % 2) // 2)) + (15 + 25*n + 15*(n**2) + 14*(n**3) - 3*(((-1)**n))*(5 + n*(3 + n))) // 96

STATUS

proposed

editing

Discussion
Thu Aug 18
19:11
Torlach Rush: @Peter Luschny: the change you provided workes for display terms and 1267650600228229401496703205376, the value immediately before the point of failure. Thanks.
#26 by Jon E. Schoenfield at Sun Aug 14 23:51:34 EDT 2022
STATUS

editing

proposed

Discussion
Sun Aug 14
23:52
Jon E. Schoenfield: I added some spaces to the name; I think it helps make it more apparent at a glance what's going on.
Mon Aug 15
00:05
Torlach Rush: Output looks good, thanks Jon,
02:56
Kevin Ryde: Code wrong where I said before 2**100+1.  Due to floating point truncation at math.ceil(n/2).
03:01
Kevin Ryde: The reason to really hate floating point is that when it truncates to a wrong result it does so silently (as a rule).
07:08
Peter Luschny: Who likes to talk about his own mistakes?
07:19
Peter Luschny: Torlach, try (n + n % 2) // 2 instead. I have not tested it. But please also read a book about programming and do not do all your exercises here with us. There are more suitable places for that.
09:21
Michel Marcus: I don't see why don't you get A079824 ?
Wed Aug 17
16:43
Torlach Rush: @Kevin Ryde, @Peter Luschny I have some questions. Up to now I have provided code snippets that verify displayed terms. I am not alone in this. I continue to observe examples where code snippets stop after outputting the last displayed term.  Additionally, code snippets should be capable of producing entries in a b-file. Has something changed? The reason I ask Is the @Kevin Ryde comment where math. Ceil(n/2) fails at 2^100+1.  This means the code snippet fails at n = 1,267,650,600,228,229,401,496,703,205,377. Does OEIS facilitate b-files with this number of entries? Following from this is that the math. Ceil(n/2) failure is a computer system limitation, so even if math. Ceil(n/2) were to carry on outputting numbers are there other limitations that need to be checked? The sequence is infinite but computer/device resources are not. Where does it stop? As to suggestion by @Peter Luschny to replace math. Ceil(n/2) with (n + n % 2) // 2, if I do this should I then replace ceiling(n/2) with the same in the formula? To be clear, the code snippets I provide are not exercices but up to now serve to validate display terms. If this is not sufficient, then I will be more than happy to make my code more rigorous.
17:12
Torlach Rush: @Michel Marcus, I'm confused, the formula for A079824(n) is (15 + 25*n + 15*n^2 + 14*n^3 - 3*(((-1)^n))*(5 + n*(3 + n))) / 96, the formula for a(n) is (n * ceiling(n/2)) + ((15 + 25*n + 15*n^2 + 14*n^3 - 3*(((-1)^n))*(5 + n*(3 + n))) / 96).
Thu Aug 18
04:39
Kevin Ryde: Wrong result for any input is a bug, in a language with bignums.
04:44
Kevin Ryde: Some inputs are impractical in time or space, but make the code right for (seemingly) ever-increasing computer grunt.
04:56
Kevin Ryde: Massaging a formula to something suiting code is fine.  In this case the ceil shouldn't exist.  You already have a (-1)^n of odd/even cases and the ceil merges into there with a couple of coefficient changes.
18:41
Torlach Rush: Thanks for the explanations, I will make the required changes.
#25 by Jon E. Schoenfield at Sun Aug 14 23:51:31 EDT 2022
NAME

Sum of numbers in n-th upward diagonal of triangle the sum of {1; 2,3; 4,5,6; 7,8,9,10; ...} and {1; 2,3; 3,4,5; 4,5,6,7; ...}.

EXAMPLE

2 = A079824(1) + A093005(1) = 1 + 1.

4 = A079824(2) + A093005(2) = 2 + 2.

13 = A079824(3) + A093005(3) = 7 + 6.

20 = A079824(4) + A093005(4) = 12 + 8.

STATUS

proposed

editing

#24 by Torlach Rush at Sun Aug 14 23:49:35 EDT 2022
STATUS

editing

proposed

Discussion
Sun Aug 14
23:58
Torlach Rush: @Kevin Ryde: Send me output of code and code sample and I will help debug. Thanks,
#23 by Torlach Rush at Sun Aug 14 23:32:25 EDT 2022
PROG

def a(n): return (n * math.ceil(n/2)) + (15 + 25*n + 15*(n**2) + 14*(n**3) - 3*(((-1)**n))*(5 + n*(3 + n))) // 96

Discussion
Sun Aug 14
23:33
Torlach Rush: My bad, The code was missing a return statement,.
#22 by Torlach Rush at Sun Aug 14 23:20:15 EDT 2022
PROG

def a(n) = : (n * math.ceil(n/2)) + (15 + 25*n + 15*(n**2) + 14*(n**3) - 3*(((-1)**n))*(5 + n*(3 + n))) // 96