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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T15:59:49+00:00 2026-06-18T15:59:49+00:00

Basically, I’ve been trying to complete the 3rd question on projecteuler.net. The example gives

  • 0

Basically, I’ve been trying to complete the 3rd question on projecteuler.net. The example gives me the number 13195 which this program (writting in C) accurately returns a prime factor tree of 5 7 13 29, but when I input the question number 600851475143 nothing happens. I have also made a similar program in Python about a year ago and that solves the factor tree for 600851475143. I think it has to do with the data types I’m using but I can’t find a reliable source for information on that and how to do modulo with floats/doubles/big thingies.

Thanks,

Clement

Code:

//
//  main.c
//  Project Euler Question 3
//
//  Created by Cwbh on 2/11/13.
//  Copyright (c) 2013 Cwbh. All rights reserved.
//

#include <stdio.h>
#include <math.h>

int is_prime(int x);

int main(int argc, const char * argv[])
{
    int pft[100];
    int number;
    int pointerloc = 0;

    printf("Enter the number to find the Prime Factor Tree of: ");
    scanf("%d", &number);

    if (is_prime(number) == 0) {
        for (int i = 2; i < number; i++) {
            if (number%i == 0 && is_prime(i) == 1) {
                pft[pointerloc] = i;
                pointerloc++;
            }
        }
    }else{
        printf("You've entered a prime number to begin with!");
    }

    for (int i = 0; i < pointerloc; i++) {
        printf("%d\n",pft[i]);
    }


    return 0;
}

int is_prime(int x){
    int prime = 1;

    for (int i = 2; i < x; i++) {
        if (x%i == 0) {
            prime = 0;
            break;
        }
    }

    return prime;

}
  • 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-18T15:59:50+00:00Added an answer on June 18, 2026 at 3:59 pm

    It looks like int is a 32-bit type on your machine. That means 600851475143 won’t fit (the largest number representable in a 32 bit integer is 4294967295). Use a 64-bit type and you should be OK. You can use uint64_t from stdint.h, or maybe your machine has a 64-bit long or long long type.

    The % operator only works on integer types in C, so trying to use it for a float or double won’t work.

    Another option you have is to use a “big number” library of some kind. You can certainly write your own simple one that will suffice for Project Euler problems at this level.

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

Sidebar

Related Questions

Basically I'm trying to reprint this method every time a dropbox option is selected.
Basically I am trying to do this: <Trigger Property=Item Value={c:CollectionView.NewItemPlaceHolder}> But the syntax is
Basically what I'm trying to do is generate an alphanumeric string, which is passed
Basically, I've been trying nXhtml mode, and it's terribly slow and buggy in Emacs
Basically I want to know how I would do this. Here's an example string:
Basically, I have a list of delivery checkboxes one for deliver to this address
Basically, what I'm trying to create is a page of div tags, each has
Basically I am trying to make the in-app purchase work, but with no luck.
Basically, I want to do the opposite of this: how do i hide anchor
Basically, I have slider which I would like to be triggered from menu too.

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.