I need to solve this problem. Could someone help me?

In the interval from 1 to the given number N, your task is to find the number which has the most divisors. In case there is more than one solution, find the smallest one.

INPUT:

From the standard input read the number N ( 0 < N < 2^31 ).

OUTPUT:

The standard output should contain two numbers (one in each line). The first line should contain the (smallest) number which has the most divisors, and the second line should contain the number of divisors.

Code:this is my version, but its not absolutely correct: #include <stdio.h> #include <math.h> int main(){ int n,i,br,max,p,k; scanf("%d",&n); max=0; for(i=1;i<=n;i++){ br=0; for(k=1;k<=sqrt(i);k++){ if (i%k==0) br++; if (br>max) { max=br; p=i; } } } printf("%d\n%d\n",p,br); return 0; }