0

Hello, Is it possible that someone can help me with the following program?

There are 500 light bulbs (numbered 1 to 500) arranged in a row. Initially they are all OFF. Starting with bulb 2, all even numbered bulbs are turned ON. Next, starting with bulb 3, and visiting every third bulb, it is turned ON if it is OFF, and it is turned OFF if it is ON. This procedure is repeated for every fourth bulb, then every fifth bulb, and so on up to the 500th bulb. Write a C program to determine which bulbs are off at the end of the above exercise.

Your help would be very much appreciated.

Thanks

I have started writing some code for the problem but i'm having some problems.

here is what i have so far:

```
#include <stdio.h>
int main(){
int number[501];
int i,bulb,incr,j;
number[501]=0;
bulb=1;
bulb++;
incr=bulb;
for(i=bulb;i<=501;i=i+incr)
{
for(j=1;j<=501;j++){
if(number[j]==0){
number[j]=1;}
else
{number[j]=0;}
}
}
printf("\nThe positions of Bulbs that will be off are:\n\n ");
for(;number[i]==0;number[i]++){
printf("%d\n",i+1);
}
system("PAUSE");
return 0;
```