Skip to main content
fix spelling
Source Link
marinus
  • 31.2k
  • 7
  • 71
  • 112

APL (5554)

'The hypothenusehypotenuse of this right triangle is',3⍕.5*⍨+/⎕*2

Test:

      'The hypothenusehypotenuse of this right triangle is',3⍕.5*⍨+/⎕*2
⎕:
      9 10
The hypothenusehypotenuse of this right triangle is 13.454

Explanation:

  • ⎕*2: raise the values in the input to the second power
  • +/: take the sum
  • .5*⍨: raise the result to the 0.5th power
  • 3⍕: round to 3 decimal places

APL (55)

'The hypothenuse of this right triangle is',3⍕.5*⍨+/⎕*2

Test:

      'The hypothenuse of this right triangle is',3⍕.5*⍨+/⎕*2
⎕:
      9 10
The hypothenuse of this right triangle is 13.454

Explanation:

  • ⎕*2: raise the values in the input to the second power
  • +/: take the sum
  • .5*⍨: raise the result to the 0.5th power
  • 3⍕: round to 3 decimal places

APL (54)

'The hypotenuse of this right triangle is',3⍕.5*⍨+/⎕*2

Test:

      'The hypotenuse of this right triangle is',3⍕.5*⍨+/⎕*2
⎕:
      9 10
The hypotenuse of this right triangle is 13.454

Explanation:

  • ⎕*2: raise the values in the input to the second power
  • +/: take the sum
  • .5*⍨: raise the result to the 0.5th power
  • 3⍕: round to 3 decimal places
Source Link
marinus
  • 31.2k
  • 7
  • 71
  • 112

APL (55)

'The hypothenuse of this right triangle is',3⍕.5*⍨+/⎕*2

Test:

      'The hypothenuse of this right triangle is',3⍕.5*⍨+/⎕*2
⎕:
      9 10
The hypothenuse of this right triangle is 13.454

Explanation:

  • ⎕*2: raise the values in the input to the second power
  • +/: take the sum
  • .5*⍨: raise the result to the 0.5th power
  • 3⍕: round to 3 decimal places