kvcpk,
How would your formula work for say finding 5 for the range from 500 to 10,000?
Would you start your first set still as (5-0)+ 1 = 6 +5 +4 +3 +2 +1? What if some of these values are below 500? how do we account?
Counting Problem
-
HPengineer
- Master | Next Rank: 500 Posts
- Posts: 165
- Joined: Wed Mar 24, 2010 8:02 am
- Thanked: 2 times
- Followed by:1 members
- kvcpk
- Legendary Member
- Posts: 1893
- Joined: Sun May 30, 2010 11:48 pm
- Thanked: 215 times
- Followed by:7 members
Assuming 500 is not included,HPengineer wrote:kvcpk,
How would your formula work for say finding 5 for the range from 500 to 10,000?
Would you start your first set still as (5-0)+ 1 = 6 +5 +4 +3 +2 +1? What if some of these values are below 500? how do we account?
The problem you are asking for is same as finding sum of 5 for the range 1000 to 10000.
Because, there will be no value between 501 and 999, that has a sum of digits as 5.
So my first range header will be 1.
Hope this helps!!
"Once you start working on something,
don't be afraid of failure and don't abandon it.
People who work sincerely are the happiest."
Chanakya quotes (Indian politician, strategist and writer, 350 BC-275BC)
don't be afraid of failure and don't abandon it.
People who work sincerely are the happiest."
Chanakya quotes (Indian politician, strategist and writer, 350 BC-275BC)
-
HPengineer
- Master | Next Rank: 500 Posts
- Posts: 165
- Joined: Wed Mar 24, 2010 8:02 am
- Thanked: 2 times
- Followed by:1 members
ok lets say 500 was included... it should still work cause header would be (5-5) +1 = 1
there would only be one value from 500 to 999 thats adds up to 5...
nice solution...
there would only be one value from 500 to 999 thats adds up to 5...
nice solution...

















