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 500643
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T06:06:31+00:00 2026-05-13T06:06:31+00:00

This problem struck me as a bit odd. I’m curious how you could represent

  • 0

This problem struck me as a bit odd. I’m curious how you could represent a list of prime numbers in a database. I do not know of a single datatype that would be able to acuratly and consistently store a large amount of prime numbers. My concern is that when the prime numbers are starting to contain 1000s of digits, that it might be a bit difficult to reference form the database. Is there a way to represent a large set of primes in a DB? I’m quite sure that this has topic has been approached before.

One of the issues about this that makes it difficult is that prime numbers can not be broken down into factors. If they could this problem would be much easier.

  • 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-13T06:06:31+00:00Added an answer on May 13, 2026 at 6:06 am

    If you really want to store primes as numbers and one of questions, stopping you is “prime numbers can not be broken down into factors”, there are another thing: store it in list of modulus of any number ordered by sequence.

    Small example:

    2831781 == 2*100^3 + 83*100^2 + 17*100^1 + 81*100^0
    

    List is:

    81, 17, 83, 2
    

    In real application is useful to split by modulus of 2^32 (32-bits integers), specially if prime numbers in processing application stored as byte arrays.

    Storage in DB:

    create table PRIMES
    (
      PRIME_ID         NUMBER not null,
      PART_ORDER       NUMBER(20) not null,
      PRIME_PART_VALUE NUMBER not null
    );
    
    alter table PRIMES 
    add constraint PRIMES_PK primary key (PRIME_ID, PART_ORDER) using index;
    

    insert for example above (1647 is for example only):

    insert into primes(PRIME_ID, PART_ORDER, PRIME_PART_VALUE) values (1647, 0, 81);
    insert into primes(PRIME_ID, PART_ORDER, PRIME_PART_VALUE) values (1647, 1, 17);
    insert into primes(PRIME_ID, PART_ORDER, PRIME_PART_VALUE) values (1647, 2, 83);
    insert into primes(PRIME_ID, PART_ORDER, PRIME_PART_VALUE) values (1647, 3, 82);
    

    prime_id value can be assigned from oracle sequence …

    create sequence seq_primes start with 1 increment by 1;
    

    Get ID of next prime number to insert:

    select seq_primes.nextval from dual;
    

    select prime number content with specified id:

    select PART_ORDER, PRIME_PART_VALUE 
    from primes where prime_id = 1647 
    order by part_order
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 499k
  • Answers 499k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer I think you need a dot in front of the… May 16, 2026 at 12:31 pm
  • Editorial Team
    Editorial Team added an answer use single quote for value in option tag: Try this… May 16, 2026 at 12:31 pm
  • Editorial Team
    Editorial Team added an answer select A.TYPE - B.TYPE from table A, table B where… May 16, 2026 at 12:31 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

Okay i'm a little bit stuck on how to solve this problem. When a
I have a bit of a problem with my PHP code, I am assigning
I'm a wee bit stuck on this, and was hoping you might have some
I am stuck on this problem which I am studying for an exam tomorrow.
I am currently stuck with this problem of displaying an image using HtmlHelper class.
I'm stuck on a problem for hours now and having read everything about this
I was working through the Programming in Scala book, and was struck by a
I've had the same problem with sql for a while and as I sit
I can bind an event to a textctrl box np. The problem is I
I need to connect to a remote MySQL database and have created the following

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.