Skip to content
Programmingoneonone
Programmingoneonone

Learn everything about programming

  • Home
  • CS Subjects
    • Internet of Things (IoT)
    • Digital Communication
    • Human Values
  • Programming Tutorials
    • C Programming
    • Data structures and Algorithms
    • 100+ Java Programs
    • 100+ C Programs
  • HackerRank Solutions
    • HackerRank Algorithms Solutions
    • HackerRank C problems solutions
    • HackerRank C++ problems solutions
    • HackerRank Java problems solutions
    • HackerRank Python problems solutions
Programmingoneonone
Programmingoneonone

Learn everything about programming

HackerEarth Count Divisors problem solution

YASH PAL, 31 July 2024
In this HackerEarth Count Divisors problem solution, you have been given 3 integers – l, r, and k. Find how many numbers between l and r (both inclusive) are divisible by k. You do not need to print these numbers, you just have to find their count.
hackerEarth Count Divisors problem solution

HackerEarth Count Divisors problem solution.

import java.io.*;
import java.util.*;
class example_2
{
static Scanner sc=new Scanner(System.in);

public static void main(String args[]) throws Exception
{
int l=sc.nextInt(),r=sc.nextInt(),k=sc.nextInt();
System.out.println((r/k)-((l-1)/k));
}
}
coding problems solutions

Post navigation

Previous post
Next post

Pages

  • About US
  • Contact US
  • Privacy Policy

Follow US

  • YouTube
  • LinkedIn
  • Facebook
  • Pinterest
  • Instagram
©2025 Programmingoneonone | WordPress Theme by SuperbThemes