Simple Php Challenge - Programming - Nairaland
Nairaland Forum › Science/Technology › Programming › Simple Php Challenge (9866 Views)
| Simple Php Challenge by elvis10ten(op): 6:51am On Jul 13, 2013 |
Here is a simple php challenge: Write a program that will print all the products of 7 till 300 in the format "7 x 1 = 7, 7 x 2 = 14, ..., 7 x 300 = 2100". [b]RULES[/b]1)Only for loop is allowed. 2)Do not use "*"(multiplication sign), rather use "+"(addition) to compute the product 3)Running your script on www.ideone.com is a plus. 4)Your script should not waste much time and run on a moderate cpu. THE SHORTER THE CODES THE BETTER. |
| Re: Simple Php Challenge by spikesC(m): 8:48am On Jul 13, 2013 |
| Re: Simple Php Challenge by Nobody: 11:34am On Jul 13, 2013*. Modified: 12:46pm On Jul 13, 2013 |
http://ideone.com/GEvjpD <?php $sum = ''; for($i=1; $i < 301; $i++){ $sum .= "7 x $i =".$i / (1 / 7).', '; } echo $sum; ?> ![]() |
| Re: Simple Php Challenge by spikesC(m): 12:01pm On Jul 13, 2013 |
Judinho59: <?php elvis10ten: Here is a simple php challenge: Write a program that will print all the products of 7 till 300 in the format "7 x 1 = 7, 7 x 2 = 14, ..., 7 x 300 = 2100". RULES 1)Only for loop is allowed. 2) Do not use "*"(multiplication sign), rather use "+"(addition) to compute the product 3)Running your script on www.ideone.com is a plus. 4)Your script should not waste much time and run on a moderate cpu. |
| Re: Simple Php Challenge by Nobody: 12:02pm On Jul 13, 2013 |
No '*'.. |
| Re: Simple Php Challenge by spikesC(m): 12:04pm On Jul 13, 2013 |
Judinho59: ![]() Am on mobile now, make i come do my magic |
| Re: Simple Php Challenge by humanbean: 12:08pm On Jul 13, 2013*. Modified: 12:48am On Jul 14, 2013 |
Just started delving into programming. I don't know PHP but I took up your challenge in Python. The code is a function to accept any number from the user and output any number of multiples he desires. I used a for loop and addition as you asked, but I don't know how to test the cpu load. The main code is about 4 lines. Please point out how I can optimise this.
|
| Re: Simple Php Challenge by humanbean: 12:18pm On Jul 13, 2013*. Modified: 12:52am On Jul 14, 2013 |
humanbean: Just started delving into programming. I don't know PHP but I took up your challenge in Python. The code is a function to accept any number from the user and output any number of multiples he desires. I used a for loop and addition as you asked, but I don't know how to test the cpu load. The main code is about 4 lines. Please point out how I can optimise this.OMG. That is sooooooo not how that is supposed to appear EDIT The original post has been corrected ![]() |
| Re: Simple Php Challenge by Nobody: 12:33pm On Jul 13, 2013 |
spikes C:Hello! Am on mobile now ![]() |
| Re: Simple Php Challenge by spikesC(m): 12:33pm On Jul 13, 2013 |
http://ideone.com/aUHhPL time: 0.01s memory: 20520 kB
|
| Re: Simple Php Challenge by spikesC(m): 12:40pm On Jul 13, 2013 |
Judinho59: Hello! Am on mobile nowMake i hear ![]() |
| Re: Simple Php Challenge by Nobody: 12:45pm On Jul 13, 2013 |
Lmao!! ![]() |
| Re: Simple Php Challenge by spikesC(m): 12:50pm On Jul 13, 2013 |
Ok i won, where's my prize. Someone should get me my laptop oo ![]() |
| Re: Simple Php Challenge by Nobody: 12:57pm On Jul 13, 2013 |
spikes C: http://ideone.com/aUHhPL spikes C: Ok i won, where's my prize. Someone should get me my laptop oo On wat basis? |
| Re: Simple Php Challenge by spikesC(m): 12:59pm On Jul 13, 2013 |
Judinho59:I followed the rules, i got it right, am the first person to get it right, i got it right.... should i continue ![]() Oya, my laptop. Atleast 8GB RAM ![]() |
| Re: Simple Php Challenge by humanbean: 1:07pm On Jul 13, 2013 |
Lol. See mortal kombat don set. :-D |
| Re: Simple Php Challenge by Nobody: 2:40pm On Jul 13, 2013 |
THIS THING FIT GIVE BRAIN DAMAGE |
| Re: Simple Php Challenge by Nobody: 2:45pm On Jul 13, 2013 |
spikes C: http://ideone.com/aUHhPL ![]() |
| Re: Simple Php Challenge by Nobody: 2:47pm On Jul 13, 2013 |
QUESTION TO ALL YOU GENIUSES. WHAT WOULD BE THE BENEFIT OF A PROGRAM LIKE THIS ? OF WHAT USE WOULD IT BE ? HOW WOULD IT BE APPLIED TO EVERYDAY STUFF ? LIKE DOES IT WORK WITH CASH MACHINES OR CALCULATORS ETC ETC ? THANKS IN ADVANCE. |
| Re: Simple Php Challenge by NSNA: 2:50pm On Jul 13, 2013 |
obadiah777: QUESTION TO ALL YOU GENIUSES. WHAT WOULD BE THE BENEFIT OF A PROGRAM LIKE THIS ? OF WHAT USE WOULD IT BE ? HOW WOULD IT BE APPLIED TO EVERYDAY STUFF ? LIKE DOES IT WORK WITH CASH MACHINES OR CALCULATORS ETC ETC ? THANKS IN ADVANCE.it can be used to develop websites |
| Re: Simple Php Challenge by Nobody: 2:50pm On Jul 13, 2013 |
<?PHP $y = 7; for($i=1; $i < 301; $i++){ echo "7 times $i = $y" . "<br />"; $y += 7; } ?> http://ideone.com/gMdcCO NO MULTIPLICATION SIGN |
| Re: Simple Php Challenge by Nobody: 2:54pm On Jul 13, 2013 |
NSNA: it can be used to develop websitesAS IN BUILD A WEBSITE ? LIKE DONT THEY HAVE PRE-MADE PACKAGES THAT MAKES WEB-SITES EASY TO BUILD ? OR WHEN YOU SAY DEVELOP YOU MEAN LIKE PUT ALL THE BELLS AND WHISTLES ON A WEBSITE LIKE SAY A COUNTER OR STUFF OF THIS KIND ? HOPE I AM NOT SOUNDING TOO IGNORANT LOL. |
| Re: Simple Php Challenge by AbuMikey(m): 3:00pm On Jul 13, 2013 |
[size=64pt]I take God beg una,Make person volunteer to teach me Programming abeg!!![/size] |
| Re: Simple Php Challenge by bigt2(m): 3:05pm On Jul 13, 2013 |
Its high time for Seun to stop there smileys appearing in codes. Especially this pisses me off, and this cracks me up!!! ![]() |
| Re: Simple Php Challenge by OkikiOluwa1(m): 3:06pm On Jul 13, 2013 |
@bunmioguns, je ki a sare pari ise yi. |
| Re: Simple Php Challenge by bigt2(m): 3:07pm On Jul 13, 2013 |
Abu Mikey: [size=64pt]I take God beg una,Make person volunteer to teach me Programming abeg!!![/size]nobody aint gon help here! Trust me! ![]() |
| Re: Simple Php Challenge by Nobody: 3:08pm On Jul 13, 2013 |
which just full fp dis aftanun |
| Re: Simple Php Challenge by Boll2010: 3:08pm On Jul 13, 2013 |
Abu Mikey: [size=64pt]I take God beg una,Make person volunteer to teach me Programming abeg!!![/size]bro u can do ursef good by downloadn vid tutorials on youtube notin u tinkn 4 nw dt oyinbos avnt done so use wat uv got 4 nw,no 1 tot me web designin,netwrkn,n sql database atleast I can handle stuffs wit wat I learnt,no 1 is collectin my money no more. |
| Re: Simple Php Challenge by Djtm(m): 3:09pm On Jul 13, 2013 |
Typical 9ja school stuff. |
| Re: Simple Php Challenge by AbuMikey(m): 3:10pm On Jul 13, 2013 |
big-t:Too Bad ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
| Re: Simple Php Challenge by Ajibam: 3:11pm On Jul 13, 2013 |
elvis10ten: Here is a simple php challenge: Write a program that will print all the products of 7 till 300 in the format "7 x 1 = 7, 7 x 2 = 14, ..., 7 x 300 = 2100". [b]RULES[/b]1)Only for loop is allowed. 2)Do not use "*"(multiplication sign), rather use "+"(addition) to compute the product 3)Running your script on www.ideone.com is a plus. 4)Your script should not waste much time and run on a moderate cpu.Das D ansa boss,,just check unda dat Place.. U dn see am? |
| Re: Simple Php Challenge by ekea2001: 3:11pm On Jul 13, 2013 |
Can do this easily with pl/sql |
Please Help Me Write This Simple Php Switch Statement • Simple PHP Quiz: Kill The Rand() • Simple Php Quiz: Why Will This Code Not Work If You Are Uploading Files? • 2 • 3 • 4
My New Year Resolution: 1 Million Naira A Month From Android App Dev In 2015 • Share Your Road map To Becoming A Web Developer. • Laravel:call To Undefined Method Illuminate\database\eloquent\collection::save()

No '*'..
)



