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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T02:13:31+00:00 2026-05-24T02:13:31+00:00

I would like to know how could I resolve this problem(it’s not a school

  • 0

I would like to know how could I resolve this problem(it’s not a school stuff, I program as an hobby, I’m doing the Euler’s exercises).
The problem in my code is this: char c = greatest.charAt(i);
I wondering how could I see the next i in the greatest.charAt(i).
I post my code, I thank in advance who will help me.

// Find the greatest product of five consecutive digits in the 1000-digit number

import java.util.*;
import java.io.*;

public class FIVE
{
    public static void main(String args[]) 
    {
        try{

            String greatest = "73167176531330624919225119674426574742355349194934969835203127745063262395783180169848018694788518438586156078911294949545950173795833195285320880551112540698747158523863050715693290963295227443043557668966489504452445231617318564030987111217223831136222989342338030813533627661428280644448664523874930358907296290491560440772390713810515859307960866701724271218839987979087922749219016997208880937766572733300105336788122023542180975125454059475224352584907711670556013604839586446706324415722155397 53697817977846174064955149290862569321978468622482839722413756570560574902614079729686524145351004748216637048440319989000889524345065854122758866688116427171479924442928230863465674813919123162824586178664583591245665294765456828489128831426076900422421902267105562632111110937054421750694165896040807198403850962455444362981230987879927244284909188845801561660979191338754992005240636899125607176060588611646710940507754100225698315520005593572972571636269561882670428252483600823257530420752963450";
            long TheNUMBER = 0; 
            long n = 0;    
            long count = 0;
            long provvisoryBiggest = 0;
            long countZERO = 0;
            long countBLOCK = 0;
            long X = 0; 

            for ( int i=0; i < greatest.lenght(); i++)  
            {
                for(int j=0; j<5; j++)
                {
                    if(X == 0)
                    {
                        X = 1;
                    }
                    char c = greatest.charAt(i); 
                    n = Character.getNumericValue(c);
                    count++;
                    System.out.println(count + "th number: " + n);
                    X = (X * n );
                    System.out.println("The product is: " + X);

                    while (provvisoryBiggest < X)
                    {
                        provvisoryBiggest = X;
                    }
                    while(count == 5) 
                    {
                        System.out.println("Now the biggest one is: " + provvisoryBiggest);
                        count = countZERO;
                        X = countZERO;
                        countBLOCK++;
                        System.out.println("Block number: "+ countBLOCK);
                        System.out.println("------------------------------------");
                    }
                }
            } 
            }
           catch(ArrayIndexOutOfBoundsException ex) { System.out.println("ARRAY ERROR"); }
           catch(ArithmeticException ex) { System.out.println("MATH ERROR");}
           catch(NumberFormatException ex) { System.out.println("NUMBER FORMAT EXCEPTION");}
           catch(StringIndexOutOfBoundsException ex) { System.out.println("INDEX ERROR"); }
    }}
  • 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-24T02:13:32+00:00Added an answer on May 24, 2026 at 2:13 am

    Looking at the output of your program, I see that it has blocks like this:

    1th number: 8
    The product is: 8
    2th number: 8
    The product is: 64
    3th number: 8
    The product is: 512
    4th number: 8
    The product is: 4096
    5th number: 8
    The product is: 32768
    Now the biggest one is: 59049
    Block number: 684
    

    This illustrates that for your subsequence of five numbers, you’re actually just multiplying one of them by itself five times.

    You need to make sure you iterate that subsequence to get the product.

    It looks like the problem is in your line greatest.charAt(i). You actually need to add the offset j to get each digit in your five-digit subsequence.

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

Sidebar

Related Questions

I would like to know if there is any way that I could build
I would like to know if an instance implements a specific method. I could
I would like to know how could i block the dial, home , back
I would like to know how I could build a dialogbox in VB.net that
i would like know some reference. I know i can googling it. but prefer
Would like to know what a programmer should know to become a good at
Would like to know the c# code to actually retrieve the IP type: Static
I would like to know if I can open 2 different diagrams using MS
I would like to know which dependency described in my pom.xml brings a transitive
I would like to know what semaphores, messageQueues, etc... are active in my vxWorks

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.