Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,143,424 members, 7,781,235 topics. Date: Friday, 29 March 2024 at 11:05 AM

Another Simple Php/python/asp/etc Challenge - Webmasters - Nairaland

Nairaland Forum / Science/Technology / Webmasters / Another Simple Php/python/asp/etc Challenge (833 Views)

How To Create A Simple Php/mysql Search / How To Create A Simple PHP Website With PBNL Anybody Can Do It! (naijazoom.com) / What Is Wrong With This Simple PHP - MYSQL Script (2) (3) (4)

(1) (Reply) (Go Down)

Another Simple Php/python/asp/etc Challenge by elvis10ten(m): 7:18am On Jul 13, 2013
Given the sequence of numbers: "3, 5, 7, 9", find the sum of the 50th term and the first 20 terms. Any language is allowed.
Re: Another Simple Php/python/asp/etc Challenge by Nobody: 1:14pm On Jul 13, 2013
elvis10ten: Given the sequence of numbers: "3, 5, 7, 9", find the sum of the 50th term and the first 20 terms. Any language is allowed.

This is not a challenge, this is just addition of numbers by 2, try Project Euler its got more tougher challenge.
Re: Another Simple Php/python/asp/etc Challenge by Nobody: 2:31pm On Jul 13, 2013
pc guru:

This is not a challenge, this is just addition of numbers by 2, try Project Euler its got more tougher challenge.

grin
Re: Another Simple Php/python/asp/etc Challenge by elvis10ten(m): 4:09pm On Jul 13, 2013
pc guru:

This is not a challenge, this is just addition of numbers by 2, try Project Euler its got more tougher challenge.
Its called AP(arithemetic progression or linear), its gotten that way. Just as the topic says, its a simple challenge. And even if its simple, attempt it and prove its simple. And the question said the sum of the 50th term and the first 20 terms and not addition of 2. Am looking for some one appling some sequence and series formula on this.
Re: Another Simple Php/python/asp/etc Challenge by elvis10ten(m): 8:43pm On Jul 13, 2013
@pc guru am waiting
Re: Another Simple Php/python/asp/etc Challenge by Nobody: 8:51pm On Jul 13, 2013
elvis10ten: @pc guru am waiting

I will but currently i have 2 Reports that need to be submitted tomorrow, and i'm still chewing my biro on how to complete the analysis. By the week "Wed" i will.
Re: Another Simple Php/python/asp/etc Challenge by humanbean: 12:00am On Jul 14, 2013
(Coded in Python 2.7) grin cheesy


total = 0

def arpro(n):
val = 3 + (n - 1) * 2
return val

for n in range(1,21):
nth = arpro(n)
total += nth
print "elvis10ten, the answer to your question is ", total + arpro(50)
Re: Another Simple Php/python/asp/etc Challenge by spikesC(m): 12:09am On Jul 14, 2013
Use the code tag wink
Re: Another Simple Php/python/asp/etc Challenge by humanbean: 12:11am On Jul 14, 2013
spikes C: Use the code tag wink

Thanks bro. There really is so much I have to learn smiley
Re: Another Simple Php/python/asp/etc Challenge by elvis10ten(m): 2:36pm On Jul 14, 2013
humanbean: (Coded in Python 2.7) grin cheesy


total = 0

def arpro(n):
val = 3 + (n - 1) * 2
return val

for n in range(1,21):
nth = arpro(n)
total += nth
print "elvis10ten, the answer to your question is ", total + arpro(50)
use www.ideone.com to run the code.
Re: Another Simple Php/python/asp/etc Challenge by humanbean: 7:01pm On Jul 14, 2013
U didn't ask for that initially. That will come later. You can rest assured that it runs properly.
Re: Another Simple Php/python/asp/etc Challenge by teemy(m): 1:46pm On Jul 15, 2013
elvis10ten: Its called AP(arithemetic progression or linear), its gotten that way.

Just in case of next time, avoid the keywords that could make the contest easier or less brain wracking. Anyone could easily code with the formular of the sum of n terms of an AP.
Re: Another Simple Php/python/asp/etc Challenge by elvis10ten(m): 2:59pm On Jul 15, 2013
teemy:

Just in case of next time, avoid the keywords that could make the contest easier or less brain wracking. Anyone could easily code with the formular of the sum of n terms of an AP.
yah, thanks.
Re: Another Simple Php/python/asp/etc Challenge by humanbean: 4:15pm On Jul 15, 2013
humanbean: (Coded in Python 2.7) grin cheesy


total = 0

def arpro(n):
val = 3 + (n - 1) * 2
return val

for n in range(1,21):
nth = arpro(n)
total += nth
print "elvis10ten, the answer to your question is ", total + arpro(50)
elvis10ten: use www.ideone.com to run the code.

The results from Ideone are here - http://ideone.com/OxtlPV
(summary - time:0.08s, memory: 8888kb, output: elvis10ten, the answer to your question is 541)
Re: Another Simple Php/python/asp/etc Challenge by elvis10ten(m): 4:37pm On Jul 15, 2013
humanbean:


The results from Ideone are here - http://ideone.com/OxtlPV
(summary - time:0.08s, memory: 8888kb, output: elvis10ten, the answer to your question is 541)
BRAVO humanbean, YOU ARE THE WINNER OF THIS CHALLENGE, thanks for participating in this challenge. You are the only one that has attempted this challenge. Here is my code in php, it takes 0.1s to run http://ideone.com/C3YEs6
Re: Another Simple Php/python/asp/etc Challenge by humanbean: 8:00pm On Jul 15, 2013
Thanks Elvis. I'm about 1 month into programming so this is encouraging to me. I took a look at your code. Can I challenge you to use only one formula? smiley Can you write it without using the second formula, like I did in mine? I wrote mine to compute each of the first 20 terms manually and then sum them, as opposed to using the default formula for that, like you did. I'd like to see how its done in PHP as I don't have any PHP experience. Expecting your reply.
Re: Another Simple Php/python/asp/etc Challenge by elvis10ten(m): 9:14pm On Jul 15, 2013
humanbean: Thanks Elvis. I'm about 1 month into programming so this is encouraging to me. I took a look at your code. Can I challenge you to use only one formula? smiley Can you write it without using the second formula, like I did in mine? I wrote mine to compute each of the first 20 terms manually and then sum them, as opposed to using the default formula for that, like you did. I'd like to see how its done in PHP as I don't have any PHP experience. Expecting your reply.
i did a quick port of your code to php but a little bit improved. http://ideone.com/gmvUWz
Re: Another Simple Php/python/asp/etc Challenge by Nobody: 2:29pm On Jul 16, 2013
shocked Python's effffin' slow!!

@Humanbean Nicey! wink
Re: Another Simple Php/python/asp/etc Challenge by humanbean: 12:25am On Jul 18, 2013
Judinho59: shocked Python's effffin' slow!!

@Humanbean Nicey! wink

Lol! Thanks bruv. Seeing results from other languages, I now understand all the brouhaha about Python's speed. I also have noticed why there's a lot of noise about its small memory footprint. Learning lil by lil, day by day.

(1) (Reply)

What's Wrong With Vanguard Online? / 5 Reasons Why You Should Use Blogger Bloging Platform / Beware Of Chuksebaba!! He Is A 419ner!!

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 20
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.