Problem

2 /11


Number Divisors - Optimize

Theory Click to read/hide

Optimizing the algorithm for finding divisors of a number

It takes a lot of time to iterate over all numbers from 1 to N and check each number for a multiplicity with a large N value. 
However, it is easy to verify that there are no divisors of the number N in the interval \([N/2+1; N -1]\)  . Thus, we can reduce the number of checks by almost half.

 

C++

Python Pascal
for(int i = 1; i <= n/2; i++)     if ( n % i == 0 )      {   ...     } for i in range(1, n//2 + 1):     if n % i == 0:         ... for i:=1 to n div 2+1 do  if( n mod i =0) then     ...


You can also take into account the fact that an odd number of even divisors cannot have and iterate over the divisors of an odd number with a step of 2.
 

C++

if (n % 2 == 0)   {       for(int i = 1; i <= n/2; i++)         if ( n % i == 0 )          {               ...         }   }   else   {       for(int i = 1; i <= n/3; i = i + 2)         if ( n % i == 0 )          {               ...         }   }
Python
if n % 2 == 0:     for i in range(1, n//2 + 1):         if n % i == 0:             ... else:     for i in range(1, n//3 + 1, 2):         if n % i == 0:             ...  
Pascal
if n mod 2 = 0 then      for i:=1 to n div 2+1 do       begin        if n mod i = 0 then          // ...      end    else       i := 1;       while (i <= n div 3) do       begin           if n mod i = 0 then                // ...           i := i + 2;      end;

 

Problem

For a natural number N , determine the parity of the maximum divisor not equal to N and 1. Print the maximum divisor itself and the word "even", separated by a space, if the maximum divisor is even, and the word "odd" - if odd.

Input
The input is not a simple natural number N (1 <= N <= 109).

Imprint
Print the answer on the screen first, the maximum divisor of the number, then, separated by a space, the word "even", if the maximum divisor is even, and the word "odd" - if odd.
 
Examples
# Input Output
1 9 3 odd