# Find Values of P and Q Satisfying the Equation N = P^2.Q

In this tutorial, we will explore how to determine values of P and Q satisfying the given equation.

A whole number higher than 1 whose only elements are 1 and itself is referred to as a prime number. A whole number that may be split evenly into another number is referred to as a factor. 2, 3, 5, 7, 11, 13, 17, 19, 23 and 29 are the first few prime numbers. Composite numbers are those that have more than two components. Neither prime nor composite, number one.

The goal is to determine P and Q that satisfy the expression N = P^2.Q, where P and Q are prime numbers, provided a number N(1 ≤ N ≤ 9×1018). P and Q must be prime numbers.

Instances:

The execution of the aforementioned concept is shown below:

C++ Program:

Output 1

(If we input the value of N as 2023)

```Put a value of N:
2023
P is 17
Q is 7
```

Output 2

(If we input the value of N as 175)

```Put a value of N:
175
P is 5
Q is 7
```

Output 3

(If we input the value of N as 158)

```Put a value of N:
158
P is 9
Q is 2
```

Output 4

(If we input the value of N as 254)

```Put a value of N:
254
P is 11
Q is 2
```

We can also write the above approach in javascript.

Javascript Code:

Program 1:

Output

```P is 17
Q is 7
```

Program 2:

Output

```P is 5
Q is 7
```
• Time Complexity will be O(3√n).
• Auxiliary space will be O(1).

So that's the end of the article. I sincerely hope you find this post to be educational and useful.

### Feedback   