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

 one 3 or one 7 puzzle (Posted on 2015-08-06)
N is a 5-digit positive integer, such that:

(i) N contains at least one 3 or at least one 7, and:
(ii) N is divisible by 37.

Determine the total number of values of N satisfying the given conditions.

 No Solution Yet Submitted by K Sengupta No Rating

Comments: ( Back to comment list | You must be logged in to post comments.)
 computer solution | Comment 2 of 3 |
Depending on whether the "or" is exclusive or inclusive:

1365 if exclusive
1710 if inclusive

Presumably it's inclusive so the answer is 1710.

DefDbl A-Z
Dim crlf\$

Form1.Visible = True

Text1.Text = ""
crlf = Chr\$(13) + Chr\$(10)

For n = 10027 To 99999 Step 37
s = LTrim(Str(n))
has3 = Sgn(InStr(s, "3"))
has7 = Sgn(InStr(s, "7"))
If has3 Then
If has7 Then ctboth = ctboth + 1 Else ct3 = ct3 + 1
ElseIf has7 Then
ct7 = ct7 + 1
End If
Next

Text1.Text = Text1.Text & ct3 + ct7 & " if exclusive" & crlf
Text1.Text = Text1.Text & ct3 + ct7 + ctboth & " if inclusive" & crlf

Text1.Text = Text1.Text & crlf & " done"

End Sub

 Posted by Charlie on 2015-08-06 13:30:07

 Search: Search body:
Forums (0)