All about flooble | fun stuff | Get a free chatterbox | Free JavaScript | Avatars    
perplexus dot info

Home > Numbers > Sequences
Proximo Ultimo Sum (Posted on 2011-11-16) Difficulty: 3 of 5
Let us consider a sequence whose first term is 1.2 - and, the numbers appearing respectively to the right and the left of the decimal point of a given term are swapped and this number is added to a given term to obtain the next term.

For example, if a term is 46.78 then the next term will be 46.78+ 78.46 = 125.24.

For some of the terms in the sequence, the numbers appearing before the decimal point and the numbers appearing after the decimal point are congruent. Considering the first 30 terms, how many terms do have this property?

Note: Terms like 792.792 are deemed to have the desired property. However terms like 3870.387 do not possess this property as 3870 is not equal to 387.

See The Solution Submitted by K Sengupta    
No Rating

Comments: ( Back to comment list | You must be logged in to post comments.)
Solution computer solution | Comment 3 of 5 |

To avoid rounding problems (such as .1999999999...) it was best to keep the LHS separate from the RHS, keeping both as integers and keeping track of the decimal position, recognizing that leading zeros are possible on the RHS and that trailing zeros need to be trimmed.

  10   Lhs=1:Rhs=2:Decpos=1
  15   Rhsstr=cutspc(str(Rhs))
  20   for I=1 to 30
  30         print cutspc(str(Lhs));".";Rhsstr,
  35         if Lhs=Rhs then print "*":inc Hitct:else print
  40         Newlhs=Lhs+Rhs
  50         Lhsstr=cutspc(str(Lhs))
  60         Newdecpos=len(Lhsstr)
  70         while Newdecpos>Decpos
  80            Rhs=Rhs*10:inc Decpos
  90         wend
 100         while Decpos>Newdecpos
 110            Lhs=Lhs*10:inc Newdecpos
 120         wend
 130         Newrhs=Lhs+Rhs
 140         Newrhsstr=cutspc(str(Newrhs))
 150         if len(Newrhsstr)>Decpos then
 160            :Newlhs=Newlhs+val(left(Newrhsstr,1))
 170            :Newrhsstr=mid(Newrhsstr,2,*)
 180         while right(Newrhsstr,1)="0"
 190            Newrhsstr=left(Newrhsstr,len(Newrhsstr)-1)
 200            dec Decpos
 205         wend
 210         Rhs=val(Newrhsstr):Lhs=Newlhs:Rhsstr=Newrhsstr
 220   next
 230   print Hitct

The hits are marked with an asterisk(*), and the total of 14 is shown:

1.2
3.3     *
6.6     *
13.2
15.33
48.48   *
96.96   *
193.92
286.113
399.399 *
798.798 *
1597.596
2193.7557
9750.975
10726.95
10822.05726
16548.16548     *
33096.33096     *
66192.66192     *
132385.32384
164769.456225
620994.620994   *
1241989.241988
1483977.3661869
5145846.5145846 *
10291693.0291692
10583385.13208613
23791998.23791998       *
47583996.47583996       *
95167992.95167992       *
 14


  Posted by Charlie on 2011-11-16 14:32:25
Please log in:
Login:
Password:
Remember me:
Sign up! | Forgot password


Search:
Search body:
Forums (0)
Newest Problems
Random Problem
FAQ | About This Site
Site Statistics
New Comments (1)
Unsolved Problems
Top Rated Problems
This month's top
Most Commented On

Chatterbox:
Copyright © 2002 - 2017 by Animus Pactum Consulting. All rights reserved. Privacy Information