
- C Programming Tutorial
- C - Home
- C - Overview
- C - Environment Setup
- C - Program Structure
- C - Basic Syntax
- C - Data Types
- C - Variables
- C - Constants
- C - Storage Classes
- C - Operators
- C - Decision Making
- C - Loops
- C - Functions
- C - Scope Rules
- C - Arrays
- C - Pointers
- C - Strings
- C - Structures
- C - Unions
- C - Bit Fields
- C - Typedef
- C - Input & Output
- C - File I/O
- C - Preprocessors
- C - Header Files
- C - Type Casting
- C - Error Handling
- C - Recursion
- C - Variable Arguments
- C - Memory Management
- C - Command Line Arguments
- C Programming useful Resources
- C - Questions & Answers
- C - Quick Guide
- C - Useful Resources
- C - Discussion
C Program for Find the largest prime factor of a number?
Prime Factor− In number theory, the prime factors of a positive integer are the prime numbers that divide that integer exactly. The process of finding these numbers is called integer factorization, or prime factorization.
Example− Prime factors of 288 are: 288 = 2 x 2 x 2 x 2 x 2 x 3 x 3
Input: n = 124 Output: 31 is the largest prime factor!
Explanation
You will find all the prime factors of a number and find the largest of them. The prime factors 124 = 2 x 2 x 31. and 31 is the largest of them.
Example
#include <stdio.h> int main() { long int n; n=3453; long int div=2, ans = 0, maxFact; while(n!=0) { if(n % div !=0) div = div + 1; else { maxFact = n; n = n / div; if(n == 1) { printf("%d is the largest prime factor !",maxFact); ans = 1; break; } } } return 0; }
Output
1151 is the largest prime factor !
- Related Articles
- C Program for Find largest prime factor of a number?
- Python Program for Find largest prime factor of a number
- Find largest prime factor of a number using C++.
- Java Program to find largest prime factor of a number
- Finding the largest prime factor of a number in JavaScript
- Find sum of a number and its maximum prime factor in C++
- Prime Factor in C++ Program
- Find the difference between the smallest 3 digit prime number and largest 1digit prime number
- Prime factor array of a Number in JavaScript
- Largest number with prime digits in C++
- Recursive program for prime number in C++
- C/C++ Program to find the Product of unique prime factors of a number?
- C/C++ Program to find Product of unique prime factors of a number?
- C Program for efficiently print all prime factors of a given number?
- Find the largest prime number required to test as a divisor to determine if the following number is a prime number. Also determine if the number is a prime number: 117

Advertisements