C Program to Find Largest Prime Factor

The following program will help you to find the largest prime factor of a number. If you want to know know about prime factors you may visit this post by me.

Here is the C Program:

#include <stdio.h>

int main()
    long long  number;
    printf("Enter a number to know its largest prime factor: ");
    long long div=2, ans = 0, maxFact;
        if(number % div !=0)
            div = div + 1;
            maxFact  = number;
            number = number / div;

            if(number == 1){
                printf("%d is the largest prime factor !",maxFact);
                ans = 1;
    return 0;