The one glaring error is this:

int64_t maxPower = 50;int64_t results; // since maxPower is 50, you room accessing an aspect that"s the end of bounds. This is undefined behavior

Also, to do the code legal C++, one of two people declare variety of 50:

int64_t results<50>;or explain a std::vector.

When you do that and use at() instead of <>, climate you obtain a much better view of how your regime breaks. View the Live example using std::vector here.

You are watching: 9,223,372,036,854,775,808

As to the "odd number", friend are obtaining a numeric overflow here:

int64_t worth = pow(tuple, power);If tuple is 3, and power is 41, then the worth overflows the int64_t type.

Maybe you should use an arbitrarily precision library (one that preferably has overloaded the requisite mathematical operators) or compose your own, instead of utilizing the "regular" C++ types. Climate you won"t or shouldn"t overflow.

enhance this answer
edited january 17 "16 in ~ 2:20
answered january 17 "16 at 1:50

32.3k44 gold badges2121 silver badges4141 bronze badges
include a comment |

your Answer

Thanks for contributing solution to stack Overflow!

Please be sure to answer the question. Provide details and also share her research!

But avoid

Asking because that help, clarification, or responding to other answers.Making statements based on opinion; ago them increase with recommendations or an individual experience.

To discover more, view our advice on writing good answers.

See more: What Is Horse Sperm Used For

Draft saved
Draft discarded

Sign up or log in

sign up using Google
sign up using Facebook
authorize up using Email and Password

Post as a guest

email Required, yet never shown

Post as a guest


Required, however never shown

post Your prize Discard

By click “Post your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the price you're looking for? Browse other questions tagged c++ or ask your own question.

The Overflow Blog
Upcoming events
Featured ~ above Meta
Why deserve to templates just be imposed in the header file?
Why go std::ends cause string comparison come fail?
Why is "using namespace std;" considered poor practice?
Why carry out we need virtual features in C++?
Why space elementwise enhancements much quicker in separate loops 보다 in a linked loop?
Why does changing 0.1f to 0 slow down performance by 10x?
Why is reading lines native stdin much slower in C++ 보다 Python?
Why is processing a sorted array faster than processing an unsorted array?
Why should I use a tip rather 보다 the thing itself?
relocate constructor dubbed twice as soon as move-constructing a std::function from a lambda that has by-value catches
warm Network questions an ext hot concerns

concern feed
subscribe to RSS
inquiry feed To subscribe to this RSS feed, copy and paste this URL right into your RSS reader.


ridge Overflow
ridge Exchange Network
site design / logo © 2021 stack Exchange Inc; user contributions license is granted under cc by-sa. Rev2021.10.19.40496

Stack Overflow works ideal with JavaScript allowed

her privacy

By click “Accept every cookies”, you agree stack Exchange deserve to store cookies on your maker and disclose details in accordance with our Cookie Policy.