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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T12:23:12+00:00 2026-05-22T12:23:12+00:00

I was solving this problem6 , I dont even know the answer but, when

  • 0

I was solving this problem6, I dont even know the answer but, when I finished I think that I will get Ok, but my answers fails, 7910956276398901303 this is my answer 1303, can you help me with this error, I dont understand what is wrong my logic , code??, Its just a simple power function

Corrected

this is the correct code

import java.math.BigDecimal;

public class Problema6 {

static BigDecimal sum = BigDecimal.valueOf(0);
static BigDecimal num = BigDecimal.valueOf(0);

public static void main(String args[]) {
    int n = 2;

    for (int i = 1; i <= 15; i++) {
        sum = sum.add(power(i, n));
        n++;
    }
    System.out.println(sum);

    String number = sum.toString();

    System.out.println(number.substring(number.length() - 4, number.length()));

}

public static BigDecimal power(int x, int y) {

    num = BigDecimal.valueOf(x).pow(y).add(BigDecimal.valueOf(y).pow(x));

    return num;
}

}

  • 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-22T12:23:12+00:00Added an answer on May 22, 2026 at 12:23 pm

    I think the problem is with using Math.pow(...). Switch to BigDecimal.pow(...) to avoid overflows

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

Sidebar

Related Questions

Hello I am solving this task Problem28 , I think that its a easy
This sounds a bit like a trivia question, but it would help me figure
UPDATE: I now have a solution I'm much happier with that, whilst not solving
I am solving this problem. I am implementing cycling mapping, I have 4 processors,
Summary: How would I go about solving this problem? Hi there, I'm working on
QUESTION Can someone help walk me through the general approach to solving this problem?
my apologies if this question doesn't make much sense, but I'm new(ish) to Actionscript,
I've had a go at solving the Eternity puzzle (1,000,000 GBP prize) and Netflix
I am in the middle of solving a problem which requires me to do
I have the following problem in my Data Structures and Problem Solving using Java

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.