Hello,

There are some similar tricks for determining if a number is a prime one. If you add the last two digits and the previous ones and the result is divisible by 11, the number is divisible by 11. In this case of Kartik's example, 21 +23 = 44 which is divisible by 11. I have forgotten some tricks which can determine dibisibility by 7.

In C / C++ lessons, you may be asked to write a utility for finding out a prime number.

With best regards,
Amiyo Biswas.
Cell: 9433464329
----- Original Message ----- From: "Kartik Sawhney" <sawhney.kar...@gmail.com>
To: <accessindia@accessindia.org.in>
Sent: Thursday, September 02, 2010 11:01 AM
Subject: Re: [AI] formula for prime numbers


Hi,

In order to compute and determine if a large number is
prime/composite, adopt the following method:

For example sake I'll use the number 2,321

1) Find the square root of the number - The Square root of 2,321 is 48.176...

2) remember that if the square root results in an integer it is
automatically composite

3) if your number ends in a 0,2,4,5,6,8 it is NOT PRIME
- 2,321 ends in a 1, so we keep going

4) add up the digits of your number, if the sum is divisible by 3,
your number is composite (basically testing the divisibility of the
number by 3)-2+3+2+1= 8 3 does not go into 8 evenly- onto the next
step

5) Divide the number by all the prime numbers less than the square
root (you can skip 2, 3, and 5)
-since the square root of 2,321 is 48.176..., we need to
try dividing 2,321 by primes less than 48
(7,11,13,17,19,23,29,31,37,41,43,47) since 2,321 is
divisible by 11, it is NOT prime and therefore composite.

6) If a number is not divisible by any of the prime numbers less than
the square, it is PRIME, if it is, it's COMPOSITE.

I hope this will help you.

-Kartik

Voice your thoughts in the blog to discuss the Rights of persons with disability bill at:
http://www.accessindia.org.in/harish/blog.htm

To unsubscribe send a message to accessindia-requ...@accessindia.org.in with the subject unsubscribe.

To change your subscription to digest mode or make any other changes, please visit the list home page at http://accessindia.org.in/mailman/listinfo/accessindia_accessindia.org.in


Voice your thoughts in the blog to discuss the Rights of persons with 
disability bill at:
http://www.accessindia.org.in/harish/blog.htm

To unsubscribe send a message to accessindia-requ...@accessindia.org.in with 
the subject unsubscribe.

To change your subscription to digest mode or make any other changes, please 
visit the list home page at
 http://accessindia.org.in/mailman/listinfo/accessindia_accessindia.org.in

Reply via email to