ง่าย 0 ข้อที่แก้แล้ว อัตราผ่าน 0%

Square a Number

Multiply an integer by itself.

Return n multiplied by itself. The square of a negative number is positive.

Implement square_number(n).

Input

n: Any integer in the allowed range.

Output

Return n × n.

เงื่อนไข

−3,000,000,000 ≤ n ≤ 3,000,000,000, so the square fits a signed 64-bit integer.

ตัวอย่าง

ตัวอย่างที่ 1
อินพุต:
n = 12

ผลลัพธ์ที่คาดหวัง:
expected = 144
อินพุต:
long long n = 12;

ผลลัพธ์ที่คาดหวัง:
long long expected = 144;
อินพุต:
long n = 12;

ผลลัพธ์ที่คาดหวัง:
long expected = 144;

คำอธิบาย

12 × 12 = 144.

ตัวอย่างที่ 2
อินพุต:
n = -7

ผลลัพธ์ที่คาดหวัง:
expected = 49
อินพุต:
long long n = -7;

ผลลัพธ์ที่คาดหวัง:
long long expected = 49;
อินพุต:
long n = -7;

ผลลัพธ์ที่คาดหวัง:
long expected = 49;

คำอธิบาย

(−7) × (−7) = 49.

เรียนรู้จากคนอื่น

แนวทางจากชุมชน

ยังไม่มีวิธีทำที่เผยแพร่ ลองแก้โจทย์นี้เพื่อแชร์วิธีแรก