I know this is probably a very simple question but how would I do something like
n2 in a programming language?
Is it n * n? Or is there another way?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
n * nis the easiest way.For languages that support the exponentiation operator (
**in this example), you can also don ** 2Otherwise you could use a Math library to call a function such as
pow(n, 2)but that is probably overkill for simply squaring a number.