- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP

- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who

The *unique prime factors* is a factor of the number that is a prime number too. In this problem, we have to find the product of all unique prime factors of a number. A *prime number* is a number that has only two factors, the number and one.

Here we will try to find the best way to calculate the product of unique prime factors of a number. let's take an example to make the problem more clear.

There is a number say n = 1092, we have to get the product of unique prime factors of this. The prime factors of 1092 are 2, 3, 7, 13 there product is 546.

2 to find this an easy approach will be to find all the factors of the number and check if the factor is a prime number. if it then multiplies it to the number and then returns the multiply variable.

Input: n = 10 Output: 10

Here, the input number is 10 having only 2 prime factors and they are 5 and 2.

And hence their product is 10.

Using a loop from i = 2 to n and check if i is a factor of n then check if i is the prime number itself if yes then store the product in product variable and continue this process till i = n.

#include <iostream> using namespace std; int main() { int n = 10; long long int product = 1; for (int i = 2; i <= n; i++) { if (n % i == 0) { int isPrime = 1; for (int j = 2; j <= i / 2; j++) { if (i % j == 0) { isPrime = 0; break; } } if (isPrime) { product = product * i; } } } cout << product; return 0; }

- Related Questions & Answers
- C/C++ Program to find Product of unique prime factors of a number?
- Java Program to find Product of unique prime factors of a number
- Python Program for Product of unique prime factors of a number
- Product of unique prime factors of a number in Python Program
- Maximum number of unique prime factors in C++
- Product of factors of number in C++
- Prime factors of a big number in C++
- Maximize the product of four factors of a Number in C++
- C Program to Find the minimum sum of factors of a number?
- Find all prime factors of a number - JavaScript
- C++ Program to find sum of even factors of a number?
- C Program for efficiently print all prime factors of a given number?
- How to find prime factors of a number in R?
- To find sum of even factors of a number in C++ Program?
- C Program for Find sum of odd factors of a number?

Advertisements