# Sequence Problem

Page 1 of 1

## 5 Replies - 660 Views - Last Post: 04 August 2012 - 02:43 AMRate Topic: //<![CDATA[ rating = new ipb.rating( 'topic_rate_', { url: 'http://www.dreamincode.net/forums/index.php?app=forums&module=ajax&section=topics&do=rateTopic&t=287885&amp;s=43bb49dbb9bc6307dd90b8853ed2aa18&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

### #1 Untalented

Reputation: 1
• Posts: 143
• Joined: 31-January 12

# Sequence Problem

Posted 04 August 2012 - 02:25 AM

Deleted

This post has been edited by Untalented: 04 August 2012 - 02:35 AM

Is This A Good Question/Topic? 0

## Replies To: Sequence Problem

### #2 Salem_c

• void main'ers are DOOMED

Reputation: 2030
• Posts: 3,997
• Joined: 30-May 10

## Re: Sequence Problem

Posted 04 August 2012 - 02:30 AM

1+1=2
2+2=4
3+4=7
4+7=11
5+11=16

Perhaps pass two parameters to sum, where one parameter increments (as you do now), and the other is the sum so far (those now colour coded above).

### #3 Skydiver

• Code herder

Reputation: 4845
• Posts: 15,998
• Joined: 05-May 12

## Re: Sequence Problem

Posted 04 August 2012 - 02:34 AM

On line 19, you have y = z + z; which is equivalent to y = x + x; Why not make sum() take two parameters: x and lastY, and change that line to something like y = x + lastY; ?

### #4 Untalented

Reputation: 1
• Posts: 143
• Joined: 31-January 12

## Re: Sequence Problem

Posted 04 August 2012 - 02:35 AM

Thanks

• Saucy!

Reputation: 6237
• Posts: 24,002
• Joined: 23-August 08

## Re: Sequence Problem

Posted 04 August 2012 - 02:38 AM

Do NOT delete your original post! That's just rude.

### #6 Untalented

Reputation: 1
• Posts: 143
• Joined: 31-January 12

## Re: Sequence Problem

Posted 04 August 2012 - 02:43 AM

JackOfAllTrades, on 04 August 2012 - 02:38 AM, said:

Do NOT delete your original post! That's just rude.

Sorry, someone might laugh and criticize my codes thats why i deleted it

Thank you

Skydiver and Salem_c