How to run the implementation of Dixon’s Algorithm
1) Open the notepad and copy the code there and save it with .java extension (say Exe.java).
2) Install the java software(if not present in your PC).
3) Open the command prompt.
4) Compile this .java file (Exe.java ) in the cmd by using the command javac (ex : javac Exe.java ).
5) Run this file by using “java” command (ex: java Exe)
6) Input a number which is the factor of 2 semi primes.
7) Then see the result……it will display the factors of this original number.(checked for the prime numbers upto 11 digit number)
import java.util.Scanner;
class Exe
{
public static void main(String args[])
{
Scanner ob=new Scanner(System.in);
System.out.print("n------------------n!! ENTER THE NO. !! : ");
double n=ob.nextDouble();
System.out.println("n ---------------------------------------------");
dixon(n);
}
public static double gcd(double a,double b)
{
if(b==0)
return a;
else if(b>a)
return gcd(b,a);
else
return gcd(b,a%b);
}
public static int checkprime(double n)
{
int f=0;
for(int i=2;i<=n/2;i++)
{
if(n%i==0)
{
f=1;
break;
}
}
if(f==1)
return 0;
else
return 1;
}
public static void dixon(double n)
{
int a,d,b1,d1;
double m,x,p,q;
m=Math.sqrt(n);
double c=Math.floor(m);
int f1=0;
for(double f=c+1;f<=n;f++)
{
double s,m1;
s=Math.sqrt((f*f)%n);
m1=Math.floor(s);
if((s-m1)==0)
{
if(s!=(f%n))
{
p=f+s;
q=f-s;
b1=checkprime(p);
d1=checkprime(q);
if(b1==1)
{
double z=gcd(q,n);
int b=checkprime(z);
if(b==1){
System.out.println(" -----------------------------------------------------");
System.out.println(" THE TWO FACTORS ARE "+z+" and "+p);
System.out.println(" ------------------------------------------------------");
}
}
else if(d1==1)
{
double z=gcd(p,n);
int b=checkprime(z);
if(b==1){
System.out.println("---------------------------------------------");
System.out.println(" THE TWO FACTORS ARE "+z+" and "+q);
System.out.println("---------------------------------------------");}
}
else
System.out.println("--------------- NEITHER OF THE FACTORS ARE PRIME---------" );
f1=1;
break;
}
}
if(f1==1)
break;
}
}
}
14 comments: On Dixon's implementation in java for prime number factorization
Hey there terrific website! Does running a blog similar to this require a lot of work?
I have virtually no knowledge of computer programming
however I had been hoping to start my own blog in the near future.
Anyhow, should you have any ideas or techniques for new blog owners please share.
I know this is off topic however I simply had to ask.
Cheers!
I must thank you for the efforts you've put in penning this site.
I am hoping to see the same high-grade content by you later on as well.
In fact, your creative writing abilities has encouraged
me to get my very own site now ;
I simply want to say I'm newbie to blogging and absolutely savored this web site. Most likely I'm going to bookmark your blog post . You certainly have terrific articles and reviews.
Magnificent website. Plenty of useful info here. I am sending it to a few pals ans additionally sharing
in delicious. And naturally, thanks in your sweat!
I just want to mention I'm all new to blogging and actually liked your web page. Probably I’m likely to bookmark your blog post . You really come with tremendous writings. Kudos for revealing your web site.
Your style is unique compared to other people I've read
stuff from. Many thanks for posting when you've
got the opportunity, Guess I'll just book mark this blog.
I’m not that much of a online reader to be honest but your
sites really nice, keep it up! I'll go ahead and bookmark your site to come back in the
future. All the best
my web-site :: unique gifts for baby boys
congratulations for the beautiful text
Thanks to the url with podcast.
I don't even understand how I ended up right here, however I thought this post was good.
I do not understand who you might be but definitely you're going to a famous blogger if you happen to aren't already.
Cheers!
Also visit my homepage ... car wax for black color cars
Good blog you have here.. It's difficult to find high quality writing like yours nowadays.
I really appreciate individuals like you! Take care!!
Also visit my webpage portable induction cooktop
Hi,br /Being the female family members cook, FFC?, in our household, I occasionally approach the kitchen to be a drag. I found your webpage wanting to explore pan sauces and also observed "real" sauteing! Excellent instructions! I've observed this so intimidating. Now I'm inspired to test out a different quick cooking method that by no means created sense prior to. Thanks!
http://www.6cfzsP4cu9c6cfzsP4cu9.com/6cfzsP4cu96cfzsP4cu9c
Yes. It should work. If it doesn't send us an email.
http://www.6cfzsP4cu96cfzsP4cu9.com/6cfzsP4cu96cfzsP4cu9
Good day. Very nice blog!! Man .. Excellent .. Superb .. I'll bookmark your blog and take the feeds also...I am satisfied to find so much useful information here in the article. Thanks for sharing..
behind TricksWay
very affordable cost.
mail on info@tricksway.com
like us on facebook.
Sliding Sidebar
We are India’s largest Startup Community
We are team of ' Delhi Startups ' , most active startup community with strict spam policy.
We are making !deas happen..for future, business and jobs without charging anything, with connecting entrepreneurs.. It's a reason to trust on us.
Come and join or subscribe, we will defiantly give a reason to like us.
Our Facebook Page