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

Home > Just Math
Odd and Even 2 (Posted on 2015-08-03) Difficulty: 2 of 5
Determine the sum of all 3-digit positive integers which contain at least one odd digit and at least one even digit. (For purposes of the problem, zero is an even digit.)

No Solution Yet 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 |
In the same vein as Ady's comment:

 494550 - 123775 = 370775

DefDbl A-Z
Dim crlf$


Private Sub Form_Load()
 Form1.Visible = True
 
 Text1.Text = ""
 crlf = Chr$(13) + Chr$(10)

 For n = 100 To 999
   s$ = LTrim(Str(n))
   odd = 0: even = 0
   For i = 1 To 3
     If InStr("02468", Mid(s, i, 1)) > 0 Then even = 1
     If InStr("13579", Mid(s, i, 1)) > 0 Then odd = 1
   Next
   If odd * even Then
     tot = tot + n
    Else
     totn = totn + n
     Text1.Text = Text1.Text & Str(n)
     DoEvents
   End If
   tottot = tottot + n
 Next n
 
 
 Text1.Text = Text1.Text & crlf & Str(tottot) & Str(totn) & Str(tot) & " done"
  
End Sub


  Posted by Charlie on 2015-08-03 10:15:05
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 (14)
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