Page Contents

## Path through graph Codevita 9 Solution

You are given two regular numbers. Envision these characteristic numbers as hubs on a chart. On this chart, a number is associated with its biggest factor other than itself. You need to locate the most limited way among them and print the quantity of edges on that way.

In the event that the two numbers don’t have any regular factor, at that point build a way through 1. For better comprehension allude to the models beneath:

Model 1:

Input numbers: 2 4

The numbers are straightforwardly associated as follows on the chart. 2 is simply the biggest factor of 4, other than itself.

We can likewise observe that there is just nervous between them.

4 <- – > 2

Henceforth the quantity of edges in most limited way is 1.

Yield: 1

Model 2:

Input numbers: 18 19

The chart for number 18 and 19 will resemble this. Here we have 4 edges in the way.

18 <- – > 9 <- – > 3 <- – > 1 <- – > 19

Yield: 4

Model 3:

Input numbers: 9

The quantity of edges in most limited way is zero since the numbers compare to a similar hub.

Yield: 0

Requirements

0 < M, N <= 10 ^ 9

Information

Single line containing two space isolated whole numbers M, N

Yield

Number of edges in the most limited way.

Time Limit

1

Models

Model 1

Information

15689 28

Yield

5

Clarification :

The chart for number 15689 and 28 will resemble this.

Since we realize that biggest factor of 15689 other than itself is 541.

Since 541 is a prime number, it’s biggest factor other than itself is 1.

For number 28, it’s biggest factor other than itself is 14.

Biggest factor of 14, other than itself is 7.

Since 7 is a prime number, it’s biggest factor other than itself is 1.

Along these lines, the chart will resemble this:

15689 <- – > 541 <- – > 1 <- – > 7 <- – > 14 <- – > 28

Since there are 5 edges in this diagram, yield will be 5.

Model 2

Info

16 4

Yield

2

Clarification :

The diagram for number 16 and 4 will resemble this.

Since we realize that biggest factor of 16 other than itself is 8.

Biggest factor of 8 other than itself is 4. That is the other info number, so we will stop here.

Thus, the diagram will resemble this:

16<- – >8<- – >4

Since there are 2 edges in this chart, yield will be 2.”

### Codevita Season 9 All Questions Solutions

- Single Lane Highway | Codevita 9 SOLUTIONS
- Factor of 3 Codevita 9 Solutions
- Corona Virus Codevita 9 Solutions
- String Pair Codevita 9 Solution
- 4 Particles Codevita 9 Solution
- String Word Codevita 9 Solution
- Binary Equivalent Codevita 9 Solution
- Equalize Weights Codevita 9 Solution
- Max Sum Codevita 9 Solution
- 3 Palindrome Codevita 9 Solution
- Secret Word Codevita 9 Solution
- Path through graph Codevita 9 Solution
- Unlocker codevita 9 Solution
- Tennis Score codevita 9 Solution
- 7 X 7 Codevita 9 Solution
- Railway Station Codevita 9 Solution
- Count Pairs Codevita 9 Solution