# Highest Divisor - CodeChef Solution | AskTheCode

CodeChef Feb Long Challenge Solution | Highest Divisor Solution in C | Ask The Code

Problem:

You are given an integer *N*. Find the largest integer between 1 and 10 (inclusive) which divides *N*.

### Input:

The first and only line of the input contains a single integer *N*.

### Output:

Print a single line containing one integer ― the largest divisor of *N*

between 1 and 10.

### Constraints:

2≤

*N*≤1,000

### Subtasks:

**Subtask #1 (100 points):** original constraints

### Example Input:

### 24

### Example Output:

### 8

### Explanation:

The divisors of 24

are 1,2,3,4,6,8,12,24, out of which 1,2,3,4,6,8 are in the range [1,10]. Therefore, the answer is max(1,2,3,4,6,8)=8.

Code:

#include <stdio.h>

int main(void) {

int n, count = 1;

scanf("%d",&n);

for (int i = 2; i <= 10; i++) {

if(n%i == 0){

if(count < i){

count = i;

}

}

}

printf("%d",count);

return 0;

}