form a number using consecutive numbers

Posted by Mahesh on Stack Overflow See other posts from Stack Overflow or by Mahesh
Published on 2010-04-12T22:44:51Z Indexed on 2010/04/12 22:53 UTC
Read the original article Hit count: 347

Filed under:
|

Hi,

I was puzzled with one of the question in Microsoft interview which is as given below:

A function should accept a range( 3 - 21 ) and it should print all the consecutive numbers combination's to form each number as given below:

3=1+2 5=2+3 6=1+2+3

7=3+4 9=4+5 10=1+2+3+4

11=5+6 13=6+7 15=1+2+3+4+5

17=7+8 19=8+9 21=10+11 21=1+2+3+4+5+6

could you please help me in forming this sequence in C#?

Thanks, Mahesh

© Stack Overflow or respective owner

Related posts about numbers

Related posts about generator