id/email
password
forgot password | create account
about | help | code help+videos | done | prefs
CodingBat code practice

 

gaurav.gupta@mq.edu.au loops > countMultiples
prev  |  next  |  chance

Define a function that when passed two integers (say n and k), returns the number of integers in the range 1 to n, that are divisible by k.


countMultiples(100, 7) → 14
countMultiples(10000, 13) → 769
countMultiples(1000000, 519) → 1926

...Save, Compile, Run (ctrl-enter)

int countMultiples(int n, int k) { }

Editor font size %:
Shorter output


Forget It! -- delete my code for this problem

Progress graphs:
 Your progress graph for this problem
 Random user progress graph for this problem
 Random Epic Progress Graph

Java Help

Misc Code Practice

Difficulty: 1 Post-solution available

Copyright Nick Parlante 2017 - privacy