Skip to main content
Post Closed as "Needs details or clarity" by Geobits, n̴̖̋h̷͉̃a̷̭̿h̸̡̅ẗ̵̨́d̷̰̀ĥ̷̳, trichoplax is on Codidact now, overactor, grc
Tweeted twitter.com/#!/StackCodeGolf/status/552460396037410817
Post Reopened by Timtech, TheNumberOne, DavidC, flawr, Martin Ender
added 223 characters in body
Source Link
dwana
  • 551
  • 4
  • 8

The Puzzle

You have to write a program or function p(n) that returns the square of what is entered into it and you may assume that the input is a non-negative integer. Put in simpler terms, return n2.

Rules

  1. You are not allowed to use * or / (or any other power or square root operator, such as POW or SQRT, if your language contains such functions)
  2. You may not use a loop, or use a constructions that is similar to a loop. Example of loop like constructions are GOTO and recursion.

Example

Function p(n)
Dim r()
ReDim r(n)
p = Len(Join(r, Space(n)))
End Function

Be creative and (ab)use the functions and features given to you by your language of choice.

*edit

Loop like structures are loops that allow you to repeat 1 or more instructions

-if you could add an stdout "1" to your code and you would end up with repeating that output n times, it will count as a loop

The Puzzle

You have to write a program or function p(n) that returns the square of what is entered into it and you may assume that the input is a non-negative integer. Put in simpler terms, return n2.

Rules

  1. You are not allowed to use * or / (or any other power or square root operator, such as POW or SQRT, if your language contains such functions)
  2. You may not use a loop, or use a constructions that is similar to a loop. Example of loop like constructions are GOTO and recursion.

Example

Function p(n)
Dim r()
ReDim r(n)
p = Len(Join(r, Space(n)))
End Function

Be creative and (ab)use the functions and features given to you by your language of choice.

The Puzzle

You have to write a program or function p(n) that returns the square of what is entered into it and you may assume that the input is a non-negative integer. Put in simpler terms, return n2.

Rules

  1. You are not allowed to use * or / (or any other power or square root operator, such as POW or SQRT, if your language contains such functions)
  2. You may not use a loop, or use a constructions that is similar to a loop. Example of loop like constructions are GOTO and recursion.

Example

Function p(n)
Dim r()
ReDim r(n)
p = Len(Join(r, Space(n)))
End Function

Be creative and (ab)use the functions and features given to you by your language of choice.

*edit

Loop like structures are loops that allow you to repeat 1 or more instructions

-if you could add an stdout "1" to your code and you would end up with repeating that output n times, it will count as a loop

Post Closed as "Needs details or clarity" by Sp3000, Ypnypn, es1024, Kevin Brown-Silva, FryAmTheEggman

The Puzzle

You have to write a program or function p(n) that returns the square of what is entered into it and you may assume that the input is a non-negative integer. Put in simpler terms, return n2.

Rules

  1. You are not allowed to use * or / (or any other power or square root operator, such as POW or SQRT, if your programlanguage contains such functions)
  2. You may not use a loop, or use a constructions that is similar to a loop. Example of loop like constructions are GOTO and recursion.

Example

Function p(n)
Dim r()
ReDim r(n)
p = Len(Join(r, Space(n)))
End Function

Be createcreative and (ab)use the functions and features given to you by your language of choice.

The Puzzle

You have to write a program or function p(n) that returns the square of what is entered into it and you may assume that the input is a non-negative integer. Put in simpler terms, return n2.

Rules

  1. You are not allowed to use * or / (or any other power or square root operator, such as POW or SQRT, if your program contains such functions)
  2. You may not use a loop, or use a constructions that is similar to a loop. Example of loop like constructions are GOTO and recursion.

Example

Function p(n)
Dim r()
ReDim r(n)
p = Len(Join(r, Space(n)))
End Function

Be create and (ab)use the functions and features given to you by your language of choice.

The Puzzle

You have to write a program or function p(n) that returns the square of what is entered into it and you may assume that the input is a non-negative integer. Put in simpler terms, return n2.

Rules

  1. You are not allowed to use * or / (or any other power or square root operator, such as POW or SQRT, if your language contains such functions)
  2. You may not use a loop, or use a constructions that is similar to a loop. Example of loop like constructions are GOTO and recursion.

Example

Function p(n)
Dim r()
ReDim r(n)
p = Len(Join(r, Space(n)))
End Function

Be creative and (ab)use the functions and features given to you by your language of choice.

edited tags
Link
Martin Ender
  • 197.2k
  • 67
  • 447
  • 975

Calculate n^2the square of an integer with restrictions

Post Reopened by Jordon Biondo, Ypnypn, Optimizer, ɐɔıʇǝɥʇuʎs, Digital Trauma
Almost completely rewrote - Removed edits, placed everything at bottom in body, used '`' in order to do inline code fixed some grammar issues, added bullet points (1. 2.), changed bold to title (#)
Source Link
Martin Ender
  • 197.2k
  • 67
  • 447
  • 975
Loading
Almost completely rewrote - Removed edits, placed everything at bottom in body, used '`' in order to do inline code fixed some grammar issues, added bullet points (1. 2.), changed bold to title (#)
Source Link
Loading
added 232 characters in body; edited title
Source Link
dwana
  • 551
  • 4
  • 8
Loading
Post Closed as "Needs details or clarity" by Martin Ender, xnor, manatwork, Peter Taylor, Doorknob
added 24 characters in body
Source Link
dwana
  • 551
  • 4
  • 8
Loading
Source Link
dwana
  • 551
  • 4
  • 8
Loading