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

Home > Just Math
Odd and Even 3 (Posted on 2016-04-04) Difficulty: 3 of 5
Determine the total number of values of a positive integer N having at most four digits such that:

(i) The digit 1 occurs an odd number of times in N, and:

(ii) Each of the digits 2, 0 and 6 occurs an even number of times in N. (An even number includes zero), and:

(iii ) Any of the remaining six digits may or may not occur in 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 6
The program below has a bug leading to this erroneous answer: (see later comments)


763 values of N

from

DefDbl A-Z
Dim crlf$


Private Sub Form_Load()
 Form1.Visible = True
 
 Text1.Text = ""
 crlf = Chr$(13) + Chr$(10)
 
 For n = 1 To 9999
   ns$ = LTrim(Str(n))
   For i = 1 To Len(ns)
     Select Case Mid(ns, i, 1)
      Case 0: ct0 = ct0 + 1
      Case 1: ct1 = ct1 + 1
      Case 2: ct2 = ct2 + 1
      Case 6: ct6 = ct6 + 1
     End Select
   Next
   If ct1 Mod 2 = 1 Then
   If ct0 Mod 2 = 0 Then
   If ct2 Mod 2 = 0 Then
   If ct6 Mod 2 = 0 Then
      hitct = hitct + 1
   End If
   End If
   End If
   End If
 Next
  
 Text1.Text = Text1.Text & crlf & hitct & " done"
  
End Sub

Edited on April 5, 2016, 10:28 pm
  Posted by Charlie on 2016-04-04 19:14:42

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 (13)
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