Math, asked by satikamoktan, 8 months ago

WAP to input 5 numbers and find the largest prime number if any.

Answers

Answered by ashokkumar6394
1

Step-by-step explanation:

#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;

}

Answered by Anonymous
2

Step-by-step explanation:

#include<stdio.h>

#define M 10000000000000000

int main()

{

int n=2;

while(n<=M)

{

if(isPrime(n)) //if number is prime and palindrome then print it

{

printf("%d\t",n);

}

n++;

}

return 0;

}

int isPrime(int num) //check whether number is prime or not

{

int i;

for(i=2;i<num;i++)

{

if(num%i==0)

break;

}

if(i==num)

return 1;

else

return 0;

}

Explanation :-

Above code is used to find number from rang 2 to M.

You can see value of M which is more than 6 digits .

Similarly you can specify lower limit as well as higher limit

Similar questions