• Global community
• Language:
• Deutsch
• English
• EspaÃ±ol
• FranÃ§ais
• PortuguÃªs
• æ—¥æœ¬èªžã‚³ãƒŸãƒ¥ãƒ‹ãƒ†ã‚£
Dedicated community for Japanese speakers
• í•œêµ­ ì»¤ë®¤ë‹ˆí‹°
Dedicated community for Korean speakers
Exit
• I am trying to generate an arithmetic and geometri...

# I am trying to generate an arithmetic and geometric series/sequence with JavaScript.

New Here ,
May 16, 2016 May 16, 2016

Copied

I am trying to generate an arithmetic and geometric
series/sequence with JavaScript. The thing that makes this challenging is that
I am using user input to determine different parts of the formula I am using to
generate each sequence. I have tried to run the formulas, but I found out i was
running strings through them and not numbers. How do I generate my
sequences/series and still use user input? PS, these are my formulas: (a1 is
first term, d and r are difference/ratio, and n is the nth term)

1.) a1 + d * n

2.)a1 * r^n

Views

605

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

LEGEND , May 17, 2016 May 17, 2016

User input from a form is always a string. There are several ways to convert a string to a number in JavaScript:

• pass it as an argument to Number()
• pass it as an argument to parseInt() (for an integer)
• pass it as an argument to parseFloat() (for a floating-point number)

LEGEND ,
May 17, 2016 May 17, 2016

Copied

LATEST

User input from a form is always a string. There are several ways to convert a string to a number in JavaScript:

• pass it as an argument to Number()
• pass it as an argument to parseInt() (for an integer)
• pass it as an argument to parseFloat() (for a floating-point number)