• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EST 09:36
CET 15:36
KST 23:36
  • Home
  • Forum
  • Calendar
  • Streams
  • Liquipedia
  • Features
  • Store
  • EPT
  • TL+
  • StarCraft 2
  • Brood War
  • Smash
  • Heroes
  • Counter-Strike
  • Overwatch
  • Liquibet
  • Fantasy StarCraft
  • TLPD
  • StarCraft 2
  • Brood War
  • Blogs
Forum Sidebar
Events/Features
News
Featured News
Rongyi Cup S3 - RO16 Preview3herO wins SC2 All-Star Invitational10SC2 All-Star Invitational: Tournament Preview5RSL Revival - 2025 Season Finals Preview8RSL Season 3 - Playoffs Preview0
Community News
Weekly Cups (Jan 12-18): herO, MaxPax, Solar win0BSL Season 2025 - Full Overview and Conclusion8Weekly Cups (Jan 5-11): Clem wins big offline, Trigger upsets4$21,000 Rongyi Cup Season 3 announced (Jan 22-Feb 7)19Weekly Cups (Dec 29-Jan 4): Protoss rolls, 2v2 returns7
StarCraft 2
General
StarCraft 2 not at the Esports World Cup 2026 Oliveira Would Have Returned If EWC Continued Rongyi Cup S3 - RO16 Preview herO wins SC2 All-Star Invitational PhD study /w SC2 - help with a survey!
Tourneys
$21,000 Rongyi Cup Season 3 announced (Jan 22-Feb 7) OSC Season 13 World Championship $70 Prize Pool Ladder Legends Academy Weekly Open! SC2 All-Star Invitational: Jan 17-18 Sparkling Tuna Cup - Weekly Open Tournament
Strategy
Simple Questions Simple Answers
Custom Maps
[A] Starcraft Sound Mod
External Content
Mutation # 509 Doomsday Report Mutation # 508 Violent Night Mutation # 507 Well Trained Mutation # 506 Warp Zone
Brood War
General
Gypsy to Korea [ASL21] Potential Map Candidates Which foreign pros are considered the best? BW General Discussion BW AKA finder tool
Tourneys
Small VOD Thread 2.0 [Megathread] Daily Proleagues [BSL21] Non-Korean Championship - Starts Jan 10 Azhi's Colosseum - Season 2
Strategy
Current Meta Simple Questions, Simple Answers Soma's 9 hatch build from ASL Game 2 Game Theory for Starcraft
Other Games
General Games
Nintendo Switch Thread Battle Aces/David Kim RTS Megathread Stormgate/Frost Giant Megathread Beyond All Reason Awesome Games Done Quick 2026!
Dota 2
Official 'what is Dota anymore' discussion
League of Legends
Heroes of the Storm
Simple Questions, Simple Answers Heroes of the Storm 2.0
Hearthstone
Deck construction bug Heroes of StarCraft mini-set
TL Mafia
Vanilla Mini Mafia Mafia Game Mode Feedback/Ideas
Community
General
US Politics Mega-thread Canadian Politics Mega-thread Russo-Ukrainian War Thread NASA and the Private Sector Things Aren’t Peaceful in Palestine
Fan Clubs
The herO Fan Club! The IdrA Fan Club
Media & Entertainment
Anime Discussion Thread [Manga] One Piece
Sports
2024 - 2026 Football Thread
World Cup 2022
Tech Support
Computer Build, Upgrade & Buying Resource Thread
TL Community
The Automated Ban List
Blogs
Navigating the Risks and Rew…
TrAiDoS
My 2025 Magic: The Gathering…
DARKING
Life Update and thoughts.
FuDDx
How do archons sleep?
8882
James Bond movies ranking - pa…
Topin
Customize Sidebar...

Website Feedback

Closed Threads



Active: 1736 users

Light bulbs math problem

Blogs > jtan
Post a Reply
jtan
Profile Blog Joined April 2003
Sweden5891 Posts
February 23 2008 18:26 GMT
#1
Yes this one is also pretty classic, I've seen it on tl.net before but without a proper solution!


So in a room you have a line of 100 light bulbs with individual light switches. All are off from start. Outside sits 100 people (perhaps the 100 prisoners?)

Person number 1 goes into the room and flips all switches.
Person number 2 goes into the room and flips switch 2,4,6,8...100
Person number 3 flips switches 3,6,9,12...
...
Person number i flips switches i,2i,3i,4i...

After all 100 persons have done this, what bulbs are lit?

And how many bulbs would be lit if there were n bulbs and persons?

Please don't post anything you didn't come up with yourself!

Good luck!

****
Enter a Uh
Dromar
Profile Blog Joined June 2007
United States2145 Posts
Last Edited: 2008-02-23 18:40:22
February 23 2008 18:39 GMT
#2
First thing that comes to mind is that

+ Show Spoiler +
all prime numbers will be switched off, since they are divisible by only one and themselves.


Maybe I'll think more about it later.
Slithe
Profile Blog Joined February 2007
United States985 Posts
Last Edited: 2008-02-23 18:41:05
February 23 2008 18:40 GMT
#3
more generally, if there's an odd number of factors, a light bulb will be on.

But factoring is NP-hard...
Sadir
Profile Blog Joined December 2005
Vatican City State1176 Posts
Last Edited: 2008-02-23 19:00:27
February 23 2008 18:41 GMT
#4

+ Show Spoiler +

how many prime factors there are
u have to count prime factors, which occur double only once
but u have to consider the products of the prime factors

e.g:

2*2*3*5=60
it flips with 2,3,5,
4=2*2, 2*3=6, 2*5=10,
2*2*3=12, 2*2*5=20, 2*3*5=30
and 2*2*3*5=60

so there are 10 flips -> light on


jtan
Profile Blog Joined April 2003
Sweden5891 Posts
February 23 2008 18:44 GMT
#5
You can be more explicit!
Enter a Uh
fanatacist
Profile Blog Joined August 2007
10319 Posts
February 23 2008 18:54 GMT
#6
+ Show Spoiler +
Well, all prime bulbs will be on. That's pretty much given though. Don't feel like thinking more atm.
Peace~
LTT
Profile Blog Joined March 2003
Shakuras1095 Posts
February 23 2008 19:03 GMT
#7
+ Show Spoiler +

Well, the only lights that are going to be on are the ones that have an odd number of factors. The only way a number has an odd number of factors is if it is a square number. Eg. Factors of 4 = 1,2,4; Factors of 36 = 1,2,3,4,6,9,12,18,26

This means the bulbs that will be on will be
1^2 = 1
2^2 = 4
3^2 = 9
4^2 = 16
5^2 = 25
6^2 = 36
7^2 = 49
8^2 = 64
9^2 = 81
10^2 = 100

For the case of n bulbs, there will be floor(sqrt(n)) bulbs lit.
jtan
Profile Blog Joined April 2003
Sweden5891 Posts
Last Edited: 2008-02-23 19:20:11
February 23 2008 19:10 GMT
#8
correct LTT! Any explanation to why it's just the squares that has an odd number of positive divisors?
Enter a Uh
Slithe
Profile Blog Joined February 2007
United States985 Posts
February 23 2008 19:14 GMT
#9
On February 24 2008 04:10 jtan wrote:
correct LTT! Any explanation to why it's just the squares that has an odd # of primes in their factorization?


err do you mean odd # of factors?
jingXD
Profile Joined May 2007
United States283 Posts
Last Edited: 2008-02-23 19:17:21
February 23 2008 19:16 GMT
#10
+ Show Spoiler +

my guess:

as Slithe said, a light bulb is left on if and only if it has an odd number of factors.

I claim that every number other than a perfect square has an even number of factors.

Say you're given a number n. For every factor f there exists another factor n/f. So for each factors come in pairs. To illustrate this, consider 12 (with factors 1, 2, 3, 4, 6, 12 and factors "pairs" 1*12, 2*6, 3*4).

However, if you have a perfect square, one of the "pairs" reduces to a singlet because the "pair" consists of only one unique number. Consider 9 (with factors 1, 3, 9 and "pairs" 1*9, 3*3).

Thus, only the square of an integer will be left on after everyone flips a switch.

Now, if given a general n, exactly [[sqrt(n)]] - 1 light bulbs will be left on, since the number of perfect squares less than n is exactly the greatest integer less than sqrt(n). Consider n = 10 with 1, 4, and 9 perfect squares less than n and sqrt(10)=3.16227766.

So when n = 100, sqrt(100) = 10 light bulbs will be lit. Namely, #'s 1, 4, 9, 16, 25, 36, 49, 64, 81, and 100.



EDIT: wow, people are fast...
jtan
Profile Blog Joined April 2003
Sweden5891 Posts
Last Edited: 2008-02-23 19:20:43
February 23 2008 19:18 GMT
#11
yes ofc slithe, edited
Enter a Uh
jtan
Profile Blog Joined April 2003
Sweden5891 Posts
February 23 2008 19:34 GMT
#12
On February 24 2008 04:16 jingXD wrote:
+ Show Spoiler +

my guess:

as Slithe said, a light bulb is left on if and only if it has an odd number of factors.

I claim that every number other than a perfect square has an even number of factors.

Say you're given a number n. For every factor f there exists another factor n/f. So for each factors come in pairs. To illustrate this, consider 12 (with factors 1, 2, 3, 4, 6, 12 and factors "pairs" 1*12, 2*6, 3*4).

However, if you have a perfect square, one of the "pairs" reduces to a singlet because the "pair" consists of only one unique number. Consider 9 (with factors 1, 3, 9 and "pairs" 1*9, 3*3).

Thus, only the square of an integer will be left on after everyone flips a switch.

Now, if given a general n, exactly [[sqrt(n)]] - 1 light bulbs will be left on, since the number of perfect squares less than n is exactly the greatest integer less than sqrt(n). Consider n = 10 with 1, 4, and 9 perfect squares less than n and sqrt(10)=3.16227766.

So when n = 100, sqrt(100) = 10 light bulbs will be lit. Namely, #'s 1, 4, 9, 16, 25, 36, 49, 64, 81, and 100.



EDIT: wow, people are fast...


It's correct, gj.

Yeah people are too fast, only a few people get a chance to solve, so I guess it was a bit too easy.

I did the following:
+ Show Spoiler +

Primefactor n=P1^e1*...*Pr^er
number of factors=(e1+1)(e2+1).....(er+1)=odd <=> each factor odd <=> 2|ei for all i <=> n is square
Enter a Uh
Cambium
Profile Blog Joined June 2004
United States16368 Posts
Last Edited: 2008-02-23 20:27:07
February 23 2008 20:21 GMT
#13
+ Show Spoiler +

1
4
9
16
25
36
49
64
81
100


edit:

Yay

+ Show Spoiler [logic] +

This problem is all about number of factors.

If a number had an even number of factors (counting 1 and the number itself, not that it matters since they form a pair), then it will be off, otherwise it will be on.

Now, in order to get this number, all factors need to be paired, unless it is a perfect square, in which case, the factor pair will be the same number, and we can count it only once.

As a result, only perfect squares have odd number of factors.


+ Show Spoiler [solution checker] +

You can compile it using snippet compiler (which is awesome)

using System;
using System.Collections.Generic;

public class MyClass
{
public static void Main()
{
int[] lightbulb;
lightbulb = new int[101];

for( int i = 0; i < 101; i ++ )
{
lightbulb[i] = 0;
}
for( int j = 1; j < 101; j++ ) // people
{
for( int i = j; i < 101; i+=j ) // lightbulbs
{
lightbulb[i] ++;
if( lightbulb[i] ==2 )
{
lightbulb[i]=0;
}
if( i == 2 )
Console.WriteLine( "j=" + j +", i=" + i +"\t" + lightbulb[i]);
}
}
List<int> on = new List<int>();
for( int i = 0; i < 101; i ++)
{
if( lightbulb[i] == 1 )
{
on.Add( i );
}
}
foreach( int temp in on )
{
Console.WriteLine( temp );
}
RL();
}

#region Helper methods

private static void WL(object text, params object[] args)
{
Console.WriteLine(text.ToString(), args);
}

private static void RL()
{
Console.ReadLine();
}

private static void Break()
{
System.Diagnostics.Debugger.Break();
}

#endregion
}
When you want something, all the universe conspires in helping you to achieve it.
Cambium
Profile Blog Joined June 2004
United States16368 Posts
February 23 2008 20:21 GMT
#14
On February 24 2008 03:54 fanatacist wrote:
+ Show Spoiler +
Well, all prime bulbs will be on. That's pretty much given though. Don't feel like thinking more atm.


+ Show Spoiler +

They'll all be off?
When you want something, all the universe conspires in helping you to achieve it.
Cascade
Profile Blog Joined March 2006
Australia5405 Posts
Last Edited: 2008-02-23 20:36:11
February 23 2008 20:25 GMT
#15
That one is one of my standard math-puzzles I pull out when occasion occurs. A bit "standard", but I like it anyway. A very good problem for learning n00b puzzlesolvers. The version I heard was with santas little helpers running by and opening/closing the doors for santas raindeers. As long as it isnt a guard opening/closing prison cells, Im fine.

We should collect all these problems somewhere. Almost all of them are good.

EDIT: and speaking of light bulbs, have you seen this puzzle:

3 normal light bulbs. There are 3 switches for them somewhere far away (switches in cellar, you are at 10:th floor for example). You have to figure out which switch goes to which bulb by going down to the cellar only once. You know that if you go there a second time the horrible visit-counting Mega-Monster will eat you and all your babies and dintegrate the earth while at it. That includes your precious light bulbs. They bulbs start all turned off.

It's kinda stupid, I just came to think about it because of the bulbs. Some find it funny though.
jtan
Profile Blog Joined April 2003
Sweden5891 Posts
Last Edited: 2008-02-23 20:54:53
February 23 2008 20:53 GMT
#16
cascade: I hate that puzzle....it's physics not math

I generally don't like problems that end up having gay solutions, and a "moral" of "sometimes you can't use pure math/logic, sometimes you got to think outside the box!". I mean wtf, it's the conditions that are badly defined so that you should be fooled into making a false assumption; in that case that the system only have the boolean states of the lightbulbs as variables.

/rage
Enter a Uh
imDerek
Profile Blog Joined August 2007
United States1944 Posts
February 23 2008 21:14 GMT
#17
prime numbers have 2 factors (1 and the prime itself) so prime numbers will actually be switched off.
Least favorite progamers: Leta, Zero, Mind, Shine, free, really <-- newly added
Cascade
Profile Blog Joined March 2006
Australia5405 Posts
February 24 2008 01:16 GMT
#18
haha, I see your point jtan, and I agree. That's why I called it stupid. Still the "thinking outside the box"-point isnt all lies imo. But yeah, there are better excercises for that I guess.

Besides, YOU started it with your stupid light bulbs! You should have stayed on safe ground and used prisoners.
jtan
Profile Blog Joined April 2003
Sweden5891 Posts
February 24 2008 08:43 GMT
#19
or santas little helpers haha

but yeah agreed, that those kind of gay-problems can be fun sometimes, but it's frustrating when you spend time finding a proper solution, like I did first time I got that 3 lightbulb one
Enter a Uh
Please log in or register to reply.
Live Events Refresh
OSC
11:00
Season 13 World Championship
Classic vs herOLIVE!
Clem vs TBD
WardiTV1514
IndyStarCraft 219
LiquipediaDiscussion
RongYI Cup
11:00
Group A
ByuN vs TriGGeR
herO vs Rogue
RotterdaM744
Harstem297
BRAT_OK 151
Rex144
3DClanTV 81
CosmosSc2 71
LiquipediaDiscussion
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
RotterdaM 744
Harstem 297
IndyStarCraft 219
BRAT_OK 151
Rex 144
ProTech89
CosmosSc2 71
StarCraft: Brood War
Calm 3880
Rain 2964
Horang2 1763
Stork 912
GuemChi 688
Snow 508
ggaemo 492
BeSt 316
firebathero 288
Mini 235
[ Show more ]
Hyuk 218
Last 195
Soulkey 159
hero 144
Mong 132
Zeus 97
Barracks 91
Hyun 84
Backho 65
Sharp 57
Shuttle 52
soO 49
Movie 48
Shinee 44
Mind 37
Killer 29
JYJ 26
ToSsGirL 23
ajuk12(nOOB) 22
910 19
GoRush 18
Free 16
Terrorterran 16
Yoon 15
Icarus 13
Sacsri 11
HiyA 10
Dota 2
Gorgc4630
qojqva3184
Dendi772
Counter-Strike
olofmeister2719
shoxiejesuss1502
byalli1303
edward184
Other Games
Liquid`RaSZi1407
B2W.Neo1126
crisheroes328
Happy202
Hui .145
XaKoH 117
Mew2King103
QueenE87
Fuzer 86
Organizations
StarCraft: Brood War
Kim Chul Min (afreeca) 5
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
sctven
[ Show 18 non-featured ]
StarCraft 2
• naamasc219
• iHatsuTV 12
• Kozan
• Laughngamez YouTube
• AfreecaTV YouTube
• sooper7s
• intothetv
• Migwel
• IndyKCrew
• LaughNgamezSOOP
StarCraft: Brood War
• FirePhoenix5
• STPLYoutube
• ZZZeroYoutube
• BSLYoutube
Dota 2
• C_a_k_e 4775
• WagamamaTV406
League of Legends
• Jankos2388
• TFBlade809
Upcoming Events
RongYI Cup
20h 24m
Clem vs ShoWTimE
Zoun vs Bunny
Big Brain Bouts
1d 2h
Serral vs TBD
RongYI Cup
1d 20h
SHIN vs Creator
Classic vs Percival
OSC
1d 22h
BSL 21
2 days
RongYI Cup
2 days
Maru vs Cyan
Solar vs Krystianer
uThermal 2v2 Circuit
2 days
BSL 21
3 days
Wardi Open
3 days
Monday Night Weeklies
4 days
[ Show More ]
OSC
4 days
WardiTV Invitational
4 days
WardiTV Invitational
5 days
The PondCast
6 days
Liquipedia Results

Completed

Proleague 2026-01-20
SC2 All-Star Inv. 2025
NA Kuram Kup

Ongoing

C-Race Season 1
BSL 21 Non-Korean Championship
CSL 2025 WINTER (S19)
KCM Race Survival 2026 Season 1
Rongyi Cup S3
OSC Championship Season 13
Underdog Cup #3
BLAST Bounty Winter 2026
BLAST Bounty Winter Qual
eXTREMESLAND 2025
SL Budapest Major 2025
ESL Impact League Season 8
BLAST Rivals Fall 2025
IEM Chengdu 2025

Upcoming

Escore Tournament S1: W5
Acropolis #4 - TS4
Acropolis #4
IPSL Spring 2026
uThermal 2v2 2026 Main Event
Bellum Gens Elite Stara Zagora 2026
HSC XXVIII
Nations Cup 2026
PGL Bucharest 2026
Stake Ranked Episode 1
BLAST Open Spring 2026
ESL Pro League Season 23
ESL Pro League Season 23
PGL Cluj-Napoca 2026
IEM Kraków 2026
TLPD

1. ByuN
2. TY
3. Dark
4. Solar
5. Stats
6. Nerchio
7. sOs
8. soO
9. INnoVation
10. Elazer
1. Rain
2. Flash
3. EffOrt
4. Last
5. Bisu
6. Soulkey
7. Mini
8. Sharp
Sidebar Settings...

Advertising | Privacy Policy | Terms Of Use | Contact Us

Original banner artwork: Jim Warren
The contents of this webpage are copyright © 2026 TLnet. All Rights Reserved.