Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

vaneger

did i just break RSA?

This topic is 5452 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

ok these two functions when combined will find the primiality of a given number in so far the fastest possible time, however i dont have a larger number library to allow it to work correctly (once the number gets too big for an unsigned long it doesnt work any more). Can some one test this code for me using a large number library and tell me how its working? Also if it works correctly with bigger numbers will this break RSA encryption?
ulong factorial(ulong n)
{
	if(n<= 1)
		return n;
	ulong temp = n;
recurse:
	temp--;
	n = n * temp ;
	if(temp <= 1)
		return n;
	else
		goto recurse;
}
bool Primality(ulong n)
{
	if( (factorial(n - 1) + 1) / n == 0 )
		return true;
	return false;
}

Share this post


Link to post
Share on other sites
Advertisement
If you don't mind me asking what is the largest prime it can test? (perhaps 11)

[edit]
that's using unsigned integer

[edited by - CodeJunkie on August 13, 2003 5:52:00 PM]

Share this post


Link to post
Share on other sites
Looks like an algorithm we learned in one of my number theory courses. Dont really remember what is was called tho

Share this post


Link to post
Share on other sites
I don''t think that function works correctly, unless you happen to be talking about something other than prime versus composite numbers.

Also, this line:

(factorial(n - 1) + 1) / n == 0

boils down to:

factorial(n-1)+1 < n

due to integer division. And, if I''m not mistaken, that statement is never true...

______________________________________________________________
The Phoenix shall arise from the ashes... ThunderHawk -- ¦þ
MySite
______________________________________________________________

Share this post


Link to post
Share on other sites
quote:
Original post by vaneger
i designed it my self thanks


Sorry man, I wasn't being serious. Does this algorithm work with any prime number? Let's start with the first prime number, n=3?

if( (factorial(n - 1) + 1) / n == 0 ) :

(3-1)! + 1 = 2 + 1 = 3
3/3 != 0

doh!

Edit: Fixed my typo (forgot the minus one)




[edited by - rypyr on August 13, 2003 5:59:10 PM]

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!