So i found some time right now, and i'm going to explain you everything as if you was a 3-years old.
Sit down, so Daddy can tell you a story. /* Sarcasm /*
The correct code of mine is this:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
|
char GiantNumber = "123392181217"; //Your Giant Number here
int main()
{
unsigned int Length = strlen(GiantNumber); // String Length;
unsigned int i = 0;
while (i < (Length-5)) // While GiantNumber still has 5 Characters to be copied
{
int Product = 1; // Equals 1 so it can be multiplied
for( unsigned int j = 0; j < 5; j++)
{
Product *= GiantNumber[j+i] - '0'; // Takes Integer Value of a Char, but be sure it is a valid '0'-'9' char.
}
// Do here your comparations
}
}
|
Its comments are good enough for a middle-experienced programmer, but if you really need to go in-deep:
char GiantNumber = "123392181217"; //Your Giant Number here
Your giant number is stored as a string (a char *), and not as a number.
1 2 3 4
|
int main()
{
unsigned int Length = strlen(GiantNumber);
unsigned int i = 0;
|
The newly declared variable called Length will store the complete length of the string GiantNumber. strlen = StringLength.
The variable called 'i' will be our index. Based on I, we will go through the entire string. Let's say GiantNumber[i]. If i == 0, we will get the first character. If i == 1, we will get the second one. And so on.
While you can get 5 characters, and still get valid results...
|
int Product = 1; // Equals 1 so it can be multiplied
|
The variable Product will store the product of the next five numbers you are going to "catch". It is initialized to 1, because if we initialize it to 0, every number you are going to multiply by 0 is going to be 0.
1 2 3 4
|
for( unsigned int j = 0; j < 5; j++)
{
Product *= GiantNumber[j+i] - '0'; // Takes Integer Value of a Char, but be sure it is a valid '0'-'9' char.
}
|
Here we get 5 numbers
( The code
Product *= GiantNumber[j+i] - '0';
will be executed 5 times )
We calculate the resulting character and subtract the ASCII value of '0', which is 0x30, in hex, and then Product will multiply himself by that number.
If Product was initialized as 0, Every time Product will multiply himself, it will always become a 0.
What is left to you, is just to handle your Product variable each time-and calculate the higher Product.