Dixon's implementation in java for prime number factorization

This is a very nice java implementation of one of the best algorithm of prime number factorization i.e. “Dixon’s prime factorization” .

In number theory, prime factorization is the breaking  of a composite number  into smaller co-primes, which when multiplied together then become the  original integer.
When the numbers are very large then these integer factorization algorithm  is used.These type of algorithms are based on the difficulty of factoring large composite integers or a related problem, the “RSA problem”.
Not all numbers of a given length are equally hard to factor. The hardest instances of these problems are semi-primes, the product of two prime numbers.
Thus here is the implementation of “Dixon’s algorithm” in which it will give the factors of those prime numbers which are the multiples of semi-primes.

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)

Dixon's implementation  in java for prime number factorization by www.tricksway.com

 The code for implementation of Dixon's Algorithm is as follows:

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 ---------------------------------------------");
    public static double  gcd(double a,double b)
        return a;
        else if(b>a)
        return gcd(b,a);
        return gcd(b,a%b);
    public static int  checkprime(double n)
    int f=0;
      for(int i=2;i<=n/2;i++)
    return 0;
    return 1;
    public static void dixon(double n)
        int a,d,b1,d1;
        double m,x,p,q;
        double c=Math.floor(m);
        int f1=0;
        for(double f=c+1;f<=n;f++)
            double s,m1;
                double z=gcd(q,n);
                int b=checkprime(z);
                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);
                System.out.println("    THE TWO FACTORS ARE     "+z+"       and    "+q);
                System.out.println("--------------- NEITHER OF THE FACTORS ARE PRIME---------" );    

Himanshu is a young engineer living in India. Currently working at Cognizant as a Senior Engineer. He is an ethical hacker & blogger too, doing lots of crazy stuff... If you seem interesting, go through his portfolio: www.himstar.info : "Open Source. Millions of open minds can't be wrong!

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.

  • 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!

  • Andrew A. Sailer

    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

  • como reconquistar

    congratulations for the beautiful text

  • Johnnie Woolworth

    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.

    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!


  • Yes. It should work. If it doesn't send us an email.


  • debt consolidation

    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..

Leave a reply:

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Site Footer

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