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

Home > Just Math
Distinct sod (Posted on 2014-12-09) Difficulty: 3 of 5
A, B and C are three positive integers satisfying: A+B = 132 and B+C = 278.

How many distinct values of sod(A) + sod(C) are possible?

** sod(n) is the sum of the digits in the base ten expansion of n.

See The Solution Submitted by K Sengupta    
Rating: 5.0000 (1 votes)

Comments: ( Back to comment list | You must be logged in to post comments.)
Solution computer solution Comment 1 of 1
Twenty possible sums of sod's exist, from 10 to 29:

  10  1
  11 71
  12  3
  13  6
  14  6
  15  8
  16  9
  17 11
  18 11
  19 13
  20 71
  21 12
  22 10
  23  8
  24  7
  25  5
  26  4
  27  3
  28  1
  29 19
  
The numbers indicate how many value sets (dependent on b) result in the given number for the total of the two sod's.

DefDbl A-Z
Dim crlf$
Dim sumsod(54)

Function mform$(x, t$)
  a$ = Format$(x, t$)
  If Len(a$) < Len(t$) Then a$ = Space$(Len(t$) - Len(a$)) & a$
  mform$ = a$
End Function

Private Sub Form_Load()
 ChDir "C:\Program Files (x86)\DevStudio\VB\projects\flooble"
 Text1.Text = ""
 crlf$ = Chr(13) + Chr(10)
 Form1.Visible = True
 DoEvents
 
 sumPlus = 132 + 278
 For b = 1 To sumPlus - 131
   a = 132 - b: c = 278 - b
   tot = sod(a) + sod(c)
   sumsod(tot) = sumsod(tot) + 1
 Next b
 For i = 1 To 54
   If sumsod(i) > 0 Then
     Text1.Text = Text1.Text & mform(i, "###0") & mform(sumsod(i), "##0") & crlf
     ct = ct + 1
   End If
 Next
 Text1.Text = Text1.Text & ct & crlf

 Text1.Text = Text1.Text & " done"
End Sub

Function sod(n)
  s$ = LTrim(Str(n))
  tot = 0
  For i = 1 To Len(s$)
   tot = tot + Val(Mid(s$, i, 1))
  Next
  sod = tot
End Function



  Posted by Charlie on 2014-12-09 11:23:28
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 (17)
Unsolved Problems
Top Rated Problems
This month's top
Most Commented On

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