Whoa, nice! That's right! Congrats!

by lkt153 (no login)

Say, you wouldn't happen to find a function that generalized the sequence:
1, 3, 6, 10, 15, 21, ...

basically, the numbers are having a increasing sequence summed between them
0 + 1 = 1
1 + 2 = 3
3 + 3 = 6
6 + 4 = 10
10 + 5 = 15
...

I looked for one for quite some time, and it'd be really helpful. I use it in the recursive form:

<pre>
FUNCTION NXT%(LAST AS INTEGER, SEQ AS INTEGER)
IF (SEQ = 1) THEN
NXT% = 1
ELSE
NXT% = LAST + NXT%(LAST, SEQ - 1)
END IF
END FUNCTION
</pre>

or the iterative:

<pre>
FUNCTION NXT%(SEQ AS INTEGER)
sum = 0
FOR i% = 1 TO SEQ
sum = sum + i%
NEXT i%
NXT% = sum
END FUNCTION
</pre>

Untested, but it's just meant to give the general picture.

Any ideas would be helpful.
lkt153

Posted on Feb 14, 2009, 5:38 PM

Respond to this message   

Goto Forum Home


Response TitleAuthor and Date
I'm not even sure how to express it in BASIC on Feb 14
Look, I just found e ^ ( i * pi ) = -1 on Feb 14
I've been looking for one for leveling up. on Feb 14
 What? Carl Frederick Gauss discovered one when he was 6 years oldqbguy on Feb 14
  THANK YOU on Feb 14
  he saw how to ad series of increasing numbersLisztfr on Feb 15
  When I was 6-years old, I discovered girls! on Feb 16
   So did Gauss... on Feb 23
Closed formqbguy on Feb 14
 Close, but thank you very muchlkt153 on Feb 14
  n(n+1)(n+2) is for summing 1+3+6+10+15+...qbguy on Feb 14
   * Oh! Got it now, thank you ;) I was looking for the simpler hehlkt153 on Feb 14
 Now I have a real question. on Feb 14
  Let me explain how Tactics worked. on Feb 14
   Here is the code for Tactics: on Feb 14
    ^^^ looks a lot better formatted :( on Feb 14
  I have a chess program you can look at in the QB64 samplesqbguy on Feb 14
   Thank you. I will study it. on Feb 14
  Simulating Strategylkt153 on Feb 14