Problema
Mostra traduzioneReturn 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.
Vincoli
−3,000,000,000 ≤ n ≤ 3,000,000,000, so the square fits a signed 64-bit integer.
Esempi
Esempio 1
Input:
n = 12
Output atteso:
expected = 144
Input:
long long n = 12;
Output atteso:
long long expected = 144;
Input:
long n = 12;
Output atteso:
long expected = 144;
Spiegazione
12 × 12 = 144.
Esempio 2
Input:
n = -7
Output atteso:
expected = 49
Input:
long long n = -7;
Output atteso:
long long expected = 49;
Input:
long n = -7;
Output atteso:
long expected = 49;
Spiegazione
(−7) × (−7) = 49.