answersLogoWhite

0

What is prime num between 2 10?

Updated: 10/24/2022
User Avatar

Wiki User

10y ago

Best Answer

They are: 2 3 5 and 7

User Avatar

Wiki User

10y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: What is prime num between 2 10?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Math & Arithmetic

Write a unix shell program to print the prime numbers?

i=2 rem=1 echo "Enter a number" read num if [ $num -lt 2 ] then echo "$num is not prime" exit 0 fi while [ $i -le `expr $num / 2` -a $rem -ne 0 ] do rem=`expr $num % $i` i=`expr $i + 1` done if [ $rem -ne 0 ] then echo "$num is prime" else echo "$num is not prime" fi


How do you write a c program to find prime numbers between 1 to 10000 using functions?

You need two utility functions. The first determines if a given number is prime or not. The second finds the next prime after a given number. The following function can be used to determine if a given integer is prime: bool is_prime (const unsigned num) { if (num<2) return false; if (0==(num%2)) return num==2; unsigned max_factor = (unsigned) sqrt ((double) num) + 1; unsigned factor; for (factor=3; factor<max_factor; ++factor) if (0==(num%factor)) return false; return true; } The following function can be used to determine the next prime after the given integer: unsigned next_prime (unsigned num) { while (!is_prime (++num)); return num; } Now you can print a series of primes using the following: int main (void) { unsigned num=1; while (num<10000) { num = next_prime (num); printf ("%d is prime\n", num); } return 0; }


What is a prime number between 2 and 10?

7 is one prime number between 2 and 10.


What are prime numbers between 1 and 10?

The prime numbers between 1 and 10 are 2, 3, 5, and 7.


C plus plus program to store first 10 prime numbers in an array?

#include <iostream> bool isPrime(int p) { if( p<=1 ( p>2 && p%2==0 ))return( false );int max = (int)sqrt(( double ) p ) + 1;for( int i=3; i<=max; i+=2 )if( p%i==0 )return( false );return( true ); } int main() { int primes[10]; int count=0, num=0; while( count!= 10 ) {num+=num>2?2:1;if( isPrime(num) )primes[count++]=num;}for( int i=0; i<10; ++i )std::cout << primes[i] << std::endl;return( 0 ); }

Related questions

How do you write a C program to generate the first 50 prime numbers?

/*Determine prime numbers between 1 to 50*/ #include<stdio.h> #include<conio.h> main() { int num, i ,n; clrscr(); printf ( "\nEnter a number limit" ) ; scanf ( "%d", &n ) ; for ( num=2; num <= 50; num++ ) { for ( i=2; i <= num - 1; i++ ) { if ( num % i == 0 ) { Break; continue; } } if (num==i) printf(\n The prime number=%d", num); continue; } getch() }


Write a unix shell program to print the prime numbers?

i=2 rem=1 echo "Enter a number" read num if [ $num -lt 2 ] then echo "$num is not prime" exit 0 fi while [ $i -le `expr $num / 2` -a $rem -ne 0 ] do rem=`expr $num % $i` i=`expr $i + 1` done if [ $rem -ne 0 ] then echo "$num is prime" else echo "$num is not prime" fi


How do you write a program that prints out the first 100 prime numbers using OOP?

You do not need OOP for this because the first 100 prime numbers are all integral types. All you need is a function to determine if a given integral is prime or not, and another to find the next prime after a given integral: bool is_prime (const unsigned int num) { unsigned factor, max_factor; /* anything less than 2 is non-prime */ if (num<2) return false; /* 2 is the only even prime */ if (!(num%2) return num==2; /* determine largest potential factor of num (square root of num)*/ max_factor = sqrt (num); /* test each odd factor from 3 onwards */ for (factor=3; factor<=max_factor; factor+=2) { if (!(num%factor)) return false; /* num is non-prime */ } return true; /* the number is prime */ } unsigned next_prime (unsigned int num) { /* increment num until num is prime */ while (!is_prime (++num)); return num; } /* test the functions */ int main (void) { unsigned num, count; count=0; num=0; printf ("Printing the first 100 prime numbers:\n"); while (count<100) { num=next_prime (num); printf ("%d is prime\n", num); ++count; } return 0; }


How do you write a c program to find prime numbers between 1 to 10000 using functions?

You need two utility functions. The first determines if a given number is prime or not. The second finds the next prime after a given number. The following function can be used to determine if a given integer is prime: bool is_prime (const unsigned num) { if (num<2) return false; if (0==(num%2)) return num==2; unsigned max_factor = (unsigned) sqrt ((double) num) + 1; unsigned factor; for (factor=3; factor<max_factor; ++factor) if (0==(num%factor)) return false; return true; } The following function can be used to determine the next prime after the given integer: unsigned next_prime (unsigned num) { while (!is_prime (++num)); return num; } Now you can print a series of primes using the following: int main (void) { unsigned num=1; while (num<10000) { num = next_prime (num); printf ("%d is prime\n", num); } return 0; }


Python function that lists prime numbers?

If you just want a hint: One way to check whether a number is prime is by dividing it by any number between 2 and the square root of your number. If the number divides by any of these, it is not prime. If you want the code: import math for num in range(1,101): if all(num%i!=0 for i in range(2,int(math.sqrt(num))+1)): print num


Shell script to find a prime no?

i=2 rem=1 echo -e "Enter a number: \c" read num if [ $num -lt 2 ]; then echo -e "$num is not prime\n" exit 0 fi while [ $i -le `expr $num / 2` -a $rem -ne 0 ]; do rem=`expr $num % $i` i=`expr $i + 1` done if [ $rem -ne 0 ]; then echo -e "$num is prime\n" else echo -e "$num is not prime\n" fi


How do you write a C program to check whether a number is prime or not and to find the nth prime number?

int number; int i=2; while (i<number) { if(number%i==0) { printf("Not a prime no."); break; } else printf("number entered is prime"); getch(); }


How do you write a program in lisp to find if a number is prime or not?

(defun prime (num) (if (< 2 num) (do ((dividend 2 (1 + dividend)) (chk-to (sqrt num))) ((equal (rem num dividend) 0)) (when (<= chk-to dividend) (return t))) t))


Write a c program to generate prime numbers between 1 to 100?

#include<conio.h> #include<stdio.h> main() { int num,n,i,prime; printf("Enter any number: "); scanf("%d", &num); for(n=2; n<=num; n++) { for(int i=2; i<n; i++) { if(n%i==0) { prime=0; break; } prime=1; } if(prime) printf("\t%d",n); } getch(); }


Write a c program to accept the range of all prime numbers from 1 to n by using while loop?

#include<iosys.h> #include<math.h> // for sqrt() bool is_prime (unsigned num) { if (num<2) return false; // 2 is the first prime if (!(num%2)) return num==2; // 2 is the only even prime // largest potential factor is square root of num unsigned max = (unsigned) sqrt ((double) num) + 1; // test all odd factors for (unsigned factor=3; factor<max; factor+=2) if (!(num%factor)) return false; return true; // if we get this far, num has no factors and is therefore prime } int main (void) { // test all nums from 0 to 100 inclusive for (unsigned num=0; num<=100; ++num) { if (is_prime (num)) printf ("%d is prime\n", num); else if (num>0) printf ("%d is composite\n", num); else printf ("%d is neither prime nor composite\n", %d); } return 0; }


What is a prime number between 2 and 10?

7 is one prime number between 2 and 10.


Write a program that computes and prints X-th prime number where X equals 125 plus 20?

#include#includebool is_prime(unsigned num) {unsigned max, factor;if (num