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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T13:27:18+00:00 2026-05-28T13:27:18+00:00

I shall show you very simple example, very is calling factorial counting with recursion,

  • 0

I shall show you very simple example, very is calling factorial counting with recursion, but there is one detail which is very important, let’s look at my code , then I shall write what’s my problem.

#define PASSWORD_MAX 0x28

typedef unsigned long long longtype;

#include <iostream>

using namespace std;


longtype f(longtype n)
{
    return (n <= 1) ? 1 : f(n - 1) * n;
};

void main(void)
{
    for(longtype i = 0; i <= PASSWORD_MAX; i++)
    {
        if(f(i) != 0) cout << i << " -> " << f(i) << endl;
    };
};

After this code, I got the next result: http://pastebin.com/ZHPtJBZ7

The max result, which is readable is: 22 -> 17196083355034583040

From 23 till end , as I understand, there are only numbers in “e” power, how can I print values from 23 fully, not in shorten format?

Thanks, Best Regards!

  • 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-28T13:27:19+00:00Added an answer on May 28, 2026 at 1:27 pm

    You are getting overflow. You should use libgmp.

    Edit: Your code using GMP:

    #include <gmpxx.h>
    
    #define PASSWORD_MAX 0x28
    
    typedef mpz_class longtype;
    
    #include <iostream>
    
    using namespace std;
    
    
    longtype f(longtype n)
    {
        return (n <= 1) ? longtype(1) : f(n - 1) * n;
    };
    
    int main(void)
    {
        for( i = 0; i <= PASSWORD_MAX; i++)
        {
            if(f(i) != 0) cout << i << " -> " << f(i) << endl;
        };
    };
    

    Result:

    0 -> 1
    1 -> 1
    2 -> 2
    3 -> 6
    4 -> 24
    5 -> 120
    6 -> 720
    7 -> 5040
    8 -> 40320
    9 -> 362880
    10 -> 3628800
    11 -> 39916800
    12 -> 479001600
    13 -> 6227020800
    14 -> 87178291200
    15 -> 1307674368000
    16 -> 20922789888000
    17 -> 355687428096000
    18 -> 6402373705728000
    19 -> 121645100408832000
    20 -> 2432902008176640000
    21 -> 51090942171709440000
    22 -> 1124000727777607680000
    23 -> 25852016738884976640000
    24 -> 620448401733239439360000
    25 -> 15511210043330985984000000
    26 -> 403291461126605635584000000
    27 -> 10888869450418352160768000000
    28 -> 304888344611713860501504000000
    29 -> 8841761993739701954543616000000
    30 -> 265252859812191058636308480000000
    31 -> 8222838654177922817725562880000000
    32 -> 263130836933693530167218012160000000
    33 -> 8683317618811886495518194401280000000
    34 -> 295232799039604140847618609643520000000
    35 -> 10333147966386144929666651337523200000000
    36 -> 371993326789901217467999448150835200000000
    37 -> 13763753091226345046315979581580902400000000
    38 -> 523022617466601111760007224100074291200000000
    39 -> 20397882081197443358640281739902897356800000000
    40 -> 815915283247897734345611269596115894272000000000
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This question may look to be very simple but i don't know the answer.
I am sure this is very simple but I can't find an answer anywhere.
I'm very new in programming. The following task looks very simple but I don't
I have a very simple test page that uses XHR requests with jQuery's $.getJSON
I have written this short script (which I've stripped away some minor detail for
I have a script here, and it works amazing, except for one small detail.
I am looking for a very simple solution (using jQuery) to let a small
this is a small, but very annoying , glitch in my form. I have
I have a small (500kb) swing applet that displays very simple/limited set of small
I am having difficulty trying to get a very simple scenario working with PRISM

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.