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

Disclaimer: I'm working on Euler Problem 9. I'm adding up some pretty large numbers,
I'm working on a Project Euler problem which requires factorization of an integer. I
I am working on solving Euler project 3: Description: The prime factors of 13195
as a side project I am working on some home-baked prime generation problems, trying
I am working on a prime factorization program implemented in Java. The goal is
I'm working with the product of the first 26 prime numbers. This requires more
I am working through the project euler problems in Python 3 as a fun
You may have heard of a website called Project Euler (projecteuler.net). I'm working through
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

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.