Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 611189
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T17:45:23+00:00 2026-05-13T17:45:23+00:00

I am a student in college and have an assignment which requires finding large

  • 0

I am a student in college and have an assignment which requires finding large prime numbers. I was given the following “simple” algorithm by the professor to find 2 likely prime numbers.

  1. generate random a and p where 1 < a < p
  2. confirm that gcd(a,p) is = 1 — this is suppose to remove Carmichael numbers Edit(meant equal to 1)
  3. perform “modular exponentiation”
    if x ^ (p-1) % p = 1 where x begins at zero and increments up to p-1
    for both p and a

Example of the 3rd step.

suppose p = 5

1^4 %5 = 1

2^4 %5 = 1

3^4 %5 = 1

4^4 %5 = 1

This shows that 5 is prime.

I am realizing through this assignment that computing prime numbers is no joke. The problem I see with the above algorithm is that if I am guessing large numbers and testing them with the modular exponentiation, I could be attempting to raise a large number to a large number. This places a doubt in my mind. I have looked into Deterministic Finite Automata and the Sieve of Eratosthenes as well. Does anyone have any suggestions to either improve the given algorithm or provide any kind of assistance? Thank you for time.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T17:45:24+00:00Added an answer on May 13, 2026 at 5:45 pm

    The algorithm you’re following is called the Fermat primality test. However, there are several problems with your explanation:

    • You say “confirm that gcd(a,p) is < 1”. This doesn’t make sense as the gcd will never be less than one. What you can check is that gcd(a,p)==1. If it isn’t 1, then p is not a prime. This can detect Carmichael numbers, but may have only a small chance to do so.

    • The way the test is conducted, is that for a certain value of p, you pick several random values of a and check if a ^ (p-1) % p == 1. If one of them is not 1, then p isn’t prime. The more values of a you pick, the better your accuracy.

    • You certainly can’t check for all values of x as you say – since there are too many to check.

    • There is a fast way to perform modular exponentiation, even for large base and exponent. See the Wikipedia article. You will still need a method to perform multiplication and modulo on large integers.

    • The Sieve of Eratosthenes is only useful for finding small primes.

    • This test may incorrectly determine that Carmichael numbers are prime. Other algorithms such as Rabin-Miller don’t have this problem.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am a college student. In our college we have to develop a simple
I have a similar model Class Student(models.Model): A simple class which holds the basic
I have a website (my college website) for which each student has a username/password
Suppose I have a relationship 1 to N, for example Student , College. Student
I have recently created a student organization website (i.e. www-sc.xxx.edu/studentorganizations/ourorganization). Our college does not
I am college student (computer science) and have just started a C# programming class.
I am a college student slightly new to web programming and lately I have
I have a simple website that calculates grades of college students. There are different
I am a college student and have been asked to familiarize myself with PCCTS,
I am a broke college student. I have built a small web app in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.