Code: Select all
#include<stdio.h>
#include<math.h>
int main()
{
int no,i,nodiv,total=1,max=0;
long int n1,n2,k,n,j,number,numbers;
scanf("%d",&no);
for(i=0;i<no;i++)
{
scanf("%ld %ld",&n1,&n2);
max=0;
for(k=n1;k<=n2;k++)
{
n=k;
total=1;
for(j=2;j<=sqrt(n)+1;j++)
{
nodiv=1;
while(!(n%j))
{
nodiv++;
n/=j;
}
total*=nodiv;
}
if(n!=1)
total*=2;
if(total>max)
{
max=total;
number=k;
}
}
printf("Between %ld and %ld, %ld has a maximum of %d divisors.\n",n1,n2,number,max);
}
return 0;
}