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

  • Home
  • SEARCH
  • 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 8976957
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T19:15:54+00:00 2026-06-15T19:15:54+00:00

I read a positive integer N from the stdin and I’m trying to figure

  • 0

I read a positive integer N from the stdin and I’m trying to figure out if N is a prime number.

I know I can divide N to all the positive numbers up to sqrt(N), but that’s time consuming and my algorithm affords to give false positives from time to time so I’m looking for an heuristic to solve this.

I remember I learned about an algorithm in collage last year that would pick a number, then check if N is divisible by that number (or it’s factors) and if not, then it could tell N is a prime, but it would falsely identify it as prime about 1/40 of the time.

Does anyone recognize this algorithm I’m talking about?
A link to it would be very helpful.

  • 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-06-15T19:15:56+00:00Added an answer on June 15, 2026 at 7:15 pm

    Well, there are a few probabilistic algorithsm, some described in the wikipedia page, most likely you are speaking about Miller-Rabin Fermat Primality Test

    Note that since 2002 there is actually a O(log(n)^6) deterministic approach to determine if a number is prime – called AKS (after its developers)1


    It is an interesting issue – many thought that primality test cannot be done both polynomially in the size of the input (i.e. logarithmic in n) and both deterministically, but their approach showed otherwise.

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

Sidebar

Related Questions

Write Script to read a positive integer number then it computes the following sequence:
I'm trying to find the most efficient way to read in a positive number
First of all, I read erickson's useful reply to Why can’t I define a
I discovered a nice abstraction whereby I can read in data from UDP using
I am trying to figure out exactly what I did wrong to gain the
/** * Read a positive integer and return its value * @param the prompt
How do I read in a variable number of characters? The user can input
I was trying to read a page from the same site using PHP. I
I have been trying to figure out a weird issue with signed integers and
I am trying to check if a value I read from a text file

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.