Hi everyone,
I'm new to this sight and have a smallish amount of programming knowledge, so a simpler answer would be great.
For some reason, whenever I try to run this code with a H 13 or higher, it says that the program stopped working. I am using the Dev compiler and have tried debugging, and it says it thinks the problem is in line "divisorList[arrayCounter]=divisorTest;". However, I can't seem to figure out what the problem is...
Anything would be helpful.
Code:
#include <stdio.h>
main()
{
int H, numOfHiddenDots, arraySlots, counterH, arrayCounter, arrayResetCounter, divisorTest, divisorTestTest, divisorRunthrough;
numOfHiddenDots=0;
arraySlots=1;
int divisorList[arraySlots];
H=(whatever you want)
arraySlots=H+1;
for (counterH=1; counterH<=H; counterH++)
{
arrayCounter=1;
for (arrayResetCounter=0; arrayResetCounter<=counterH+1; arrayResetCounter++)
{
divisorList[arrayResetCounter]=0;
}
if (counterH%100==0) printf ("%d milestone reached in calculations.\n", counterH);
for (divisorTest=1; divisorTest<counterH; divisorTest++)
{
if (counterH%divisorTest==0)
{
divisorList[arrayCounter]=divisorTest;
arrayCounter++;
for (divisorTestTest=2; divisorTestTest<arrayCounter-1; divisorTestTest++)
{
if (divisorList[divisorTestTest]!=0&&divisorTest%divisorList[divisorTestTest]==0) divisorList[divisorTestTest]=0;
}
}
}
for (divisorRunthrough=1; divisorRunthrough<arrayCounter; divisorRunthrough++)
{
if (divisorList[divisorRunthrough]<=1) numOfHiddenDots=numOfHiddenDots+divisorList[divisorRunthrough]*6;
else numOfHiddenDots=numOfHiddenDots+(divisorList[divisorRunthrough]-1)*6;
}
}
printf ("The number of dots hidden from the center is: %d\n", numOfHiddenDots);
getchar();
}
Thanks