Skip to content

Commit

Permalink
Correct width of array
Browse files Browse the repository at this point in the history
  • Loading branch information
LivInTheLookingGlass committed Aug 9, 2024
1 parent b0c4e30 commit fd44839
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion cplusplus/src/p0016.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ What is the sum of the digits of the number 2**1000?


unsigned long long p0016() {
std::vector<unsigned long long> numbers(16, 0);
std::vector<unsigned long long> numbers(18, 0);
const unsigned long long ten17 = 100000000000000000;
numbers[0] = 1;
for (unsigned short i = 0; i < 1000; i++) {
Expand Down
8 changes: 4 additions & 4 deletions csharp/Euler/p0016.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,16 @@ public class p0016 : IEuler
{
public object Answer()
{
ulong[] numbers = new ulong[16];
ulong[] numbers = new ulong[18];
const ulong ten17 = 100000000000000000;
numbers[0] = 1;
for (ushort i = 0; i < 1000; i++)
{
for (byte j = 0; j < 16; j++)
for (byte j = 0; j < 18; j++)
{
numbers[j] *= 2;
}
for (byte j = 0; j < 15; j++)
for (byte j = 0; j < 17; j++)
{
if (numbers[j] > ten17)
{
Expand All @@ -37,7 +37,7 @@ public object Answer()
ulong power = 1;
for (byte i = 0; i < 19; i++)
{
for (byte j = 0; j < 16; j++)
for (byte j = 0; j < 18; j++)
{
ulong value = numbers[j] / power;
answer += value % 10;
Expand Down

0 comments on commit fd44839

Please sign in to comment.