1
\$\begingroup\$

Challenge

HP is doing research in mathematics . After doing lots of research, she struck in a problem . She found four numbers n,a, b and c .Now, She wants to know how many number exists which are less than or equal to n and are divisible by a ,b or c .

Input :

4 integers denoting n,a,b and c separated by space

Output :

intger which denotes the count of the numbers which are divisible a,b,c

Scoring:

This is , shortest code in bytes wins.

\$\endgroup\$

closed as unclear what you're asking by Dennis Jul 24 '17 at 4:55

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • 5
    \$\begingroup\$ Can you add test cases? Does the count include 0 and negative numbers? \$\endgroup\$ – fireflame241 Jul 24 '17 at 4:25
  • 3
    \$\begingroup\$ What are the ranges of the input parameters? \$\endgroup\$ – Peter Taylor Jul 24 '17 at 8:11
0
\$\begingroup\$

Python 2, 72 65 bytes

Note: This solution works for positive integers:

lambda a,b,c,n:len([x for x in range(1,n+1)if x%a*(x%b)*(x%c)<1])

Try it online!

\$\endgroup\$
0
\$\begingroup\$

Python 2, 52 bytes

lambda n,a,b,c:n/a+n/b+n/c-n/a/b-n/a/c-n/b/c+n/a/b/c

Try it online!

By the inclusion–exclusion principle.

\$\endgroup\$

Not the answer you're looking for? Browse other questions tagged or ask your own question.