Prime Factor in c


Prime factor Basic funda

In number theory, the prime factors of a positive integer are the prime numbers that divide that integer exactly. The prime factorization of a positive integer is a list of the integer's prime factors, together with their multiplicities; the process of determining these factors is called integer factorization. The fundamental theorem of arithmetic says that every positive integer has a single unique prime factorization.
To shorten prime factorization, factors are often expressed in powers (multiplicities). For example,
 360 = 2 \times 2 \times 2 \times 3 \times 3 \times 5 = 2^3 \times 3^2 \times 5,
in which the factors 2, 3 and 5 have multiplicities of 3, 2 and 1, respectively.


C program implementation of prime factor


#include<stdio.h>
#include<conio.h>
void main()
{
 int n,i,j,k;
 clrscr();
 printf("Give upper range:");
 scanf("%d",&n);
 for(i=2;i<=n;i++)
    {
for(j=2;j<=i;j++)
{
  if(n%i==0)
  {
  if(i%j==0)
   break;
  }
}
if(i==j)
 printf("The prime factor is:%d\n",j);
     }
 getch();

  }




Comments

Popular posts from this blog

Tips 01) self introduction in an interview

Computer Science Terminology

Why Failure Is Good for Success