 # Reverse Length Divisible *SSEC0020*

Given a number N, check if it is reverse length divisible. A number is said to be reverse length divisible if the first i digits of the number is divisible by (l-i-1) where l is the number of digits in N and 0 < i <= l.

For example, 652281 is reverse length divisible because:

6 is divisible by 6

65 is divisible by 5

652 is divisible by 4

6522 is divisible by 3

65228 is divisible by 2

652281 is divisible by 1.

43268 is not reverse length divisible. Print Yes if the number is reverse length divisible and no otherwise.

Boundary Conditions:

0<n<10000000

Input Format:

The first line contains the number N

Output Format:

Print “Yes” if the number is reverse length divisible otherwise print “No” (without quotes).

Example Input:

652281

Example Output:

Yes

SOLUTION

``````#include<iostream

using namespace std;

int main()
{

int n,i,j,temp,num,multi;
int count=0,
length=0;

cout << "Enter number : ";
cin >> n;

temp = n;

while(temp != 0)
{

length++;

temp /= 10;
}

for(i=1;i<length+1;i++)
{
multi=1;
num=n;

for(j=length;j>i;j--)
{
multi=multi*10;

}

num=num/multi;
if(num % (length-i+1) == 0)
{
count++;
}
}

if(length==count)
{
cout<<"Yes";
}
else
{
cout<<"No";
}
}
``````