Geek Dad, or using Perl to do math
Yesterday
littlemeridian came to me and said she knew the sum of 1+2+3... etc to 100. She had figured out a way to solve the problem without adding all the numbers.
"I can bang out a perl program that can do the math," I said, not convinced she was right (she was right, btw). So we sat at my computer and I wrote this easy program that adds consecutive numbers up to a limit you specify from <STDIN>. It took us a little while to get the math right but we eventually got it.
( see the code )
"I can bang out a perl program that can do the math," I said, not convinced she was right (she was right, btw). So we sat at my computer and I wrote this easy program that adds consecutive numbers up to a limit you specify from <STDIN>. It took us a little while to get the math right but we eventually got it.
( see the code )
