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

The Archive Base Latest Questions

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

I am working on prime factorization on large numbers (mainly, project 3 @ project

  • 0

I am working on prime factorization on large numbers (mainly, project 3 @ project Euler. I need to use the modulus on numbers declared as long long. Everytime I try to modulus that gigantic number I get a floating point exception. Any help would be profusely appreciated. Thanks.

I have run this through gdb and see what’s happening. Below is my code. It’s very rough logic at this point. Please do not give me the answer to the problem. I will gladly accept help on making this better, just please do not give me the straight up answer. Thanks 🙂

long factor(long number) {
  string br = "\n\r";
  long x = 0;
  /*this modulus variable is an attempt
  to move the answer into a long long container
  to see if that solves my floating point exception,
  it didn't*/
  long long modulus;

  while(x <= number) {
    modulus = number % x;
    if(modulus == 0) {
      cout << number/x << br;
      return factor(number/x);
    }//if number % x
    else {
      return x;
    }//else
    x++;
  }//while

}//factor
  • 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-23T03:47:46+00:00Added an answer on May 23, 2026 at 3:47 am

    Don’t try to mod by 0, it’s undefined! Doing so will result in a divide-by-zero error.

    long x = 0;
    modulus = number % x; // x is 0 here and thus not valid
    

    To expand a bit on my answer, per Wikipedia’s article on Modulo Operations

    a modulo 0 is undefined in the majority of systems, although some do define it to be a.

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

Sidebar

Related Questions

Working on a project at the moment and we have to implement soft deletion
Working on a project that parses a log of events, and then updates a
Working in Eclipse on a Dynamic Web Project (using Tomcat (v5.5) as the app
I'm working on a project in C# w/ XNA, and I want to reorganize
Here's the XML code I'm working with: <inventory> <drink> <lemonade supplier=mother id=1> <price>$2.50</price> <amount>20</amount>
Working with dates in ruby and rails on windows, I'm having problems with pre-epoch
Working with a SqlCommand in C# I've created a query that contains a IN
Working on a somewhat complex page for configuring customers at work. The setup is
Working with python interactively, it's sometimes necessary to display a result which is some
Working with TCL and I'd like to implement something like the Strategy Pattern .

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.