Count the number of divisible numbers in a given range
import java.util.Scanner;
public class Demo {
public static void main(String[] args) {
int x=1,n,count=0;
Scanner s=new Scanner(System.in);
System.out.println("Enter n value");
n=s.nextInt();
do
{
if(x%n==0)
{
count=count+1;
}
x++;
}while(x<=100);
System.out.println(count);
}
}
Output:
Enter n value
2
50
more programs visit http://sateeshm.com/