Prime Wonder

This is a discussion on Prime Wonder within the A Brief History of Cprogramming.com forums, part of the Community Boards category; Hi all, I am now working on RSA and DES encryption algorithm (college project..) Well when i was generating prime ...

  1. #1
    Its not rocket science vasanth's Avatar
    Join Date
    Jan 2002
    Posts
    1,683

    Prime Wonder

    Hi all,
    I am now working on RSA and DES encryption algorithm (college project..) Well when i was generating prime numbers i noticed one thing

    3 x 3 =9 where 3 is a prime number

    now the result 9-2 =7 where 7 is a primenumber



    7 x 7 = 49 where 7 is a prime number
    the result 49 - 2 = 47 is a prime number

    13 x 13 = 169
    the result 169 - 2 = 167 which is a prime number


    but

    373 X 373 = 139129
    and the result 139129 - 2 =139127 which is not a prime
    because 6049 x 23 = 139127


    but 50 % of the time the result for big numbers like this yeilds another primenumber... So is there anyway i can use this method to always generate big primenumbers by eliminating the non posibility numbers as 373 x 373 shown above.. And is these any theorem or study regarding the generation of prime this way.. Please help...


    thanx in advance
    Vasanth

    Here this is true for most of the smaller numbers and some bigger numbers.. But this does not work for all big numbers.... But you can say i got a 40 to 50 % sucess with bigger numbers in this way.....

  2. #2
    Code Monkey Davros's Avatar
    Join Date
    Jun 2002
    Posts
    812
    Forget your home brew prime generation technique, it won't hold water when numbers get bigger.

    Check out:

    http://www.eff.org/awards/prime-info.html
    OS: Windows XP
    Compilers: MinGW (Code::Blocks), BCB 5

    BigAngryDog.com

  3. #3
    Its not rocket science vasanth's Avatar
    Join Date
    Jan 2002
    Posts
    1,683
    Thank you very much.. Well i am now using this technique


    conside i want to find wheather 40001 is a prime number then...
    I use only odd numbers that is incerement i=i+2 starting from 3 thus saving 50 time and then dividing then original number by 2 that is 40001/2.. and trying all posibilities from 3 * 3, 3* 4 till 3 * 40001/2 and 4 * 3, 4* 4 till 4 * 40001/2 and so on...... So can i add more constraints here and make my code faster....

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Calculating prime factor of a huge number.
    By Bakster in forum C Programming
    Replies: 15
    Last Post: 02-20-2009, 11:06 AM
  2. prime number program with function
    By mackieinva in forum C Programming
    Replies: 17
    Last Post: 09-20-2007, 08:36 AM
  3. Prime Prime Prime Help Help Help
    By gtr_s15 in forum C++ Programming
    Replies: 17
    Last Post: 01-20-2006, 12:23 PM
  4. prime numbers, counters, help!
    By vege^ in forum C++ Programming
    Replies: 1
    Last Post: 03-10-2003, 03:32 PM
  5. Homework help
    By Jigsaw in forum C++ Programming
    Replies: 2
    Last Post: 03-06-2002, 04:56 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21