AlgoLounge

Fahrenheit to Celsius

easy

Given a temperature in Fahrenheit, convert it to Celsius.

Use the formula:

C = (F - 32) × (5 / 9)

Return a floating-point result (Python's normal division is fine).

Examples

Example 1

Input:  fahrenheit = 32
Output: 0.0

Water freezes at 32°F and 0°C.

Example 2

Input:  fahrenheit = 212
Output: 100.0

Example 3

Input:  fahrenheit = -40
Output: -40.0

-40 is the same on both scales.

Constraints

  • -459.67 <= fahrenheit <= 1000 (inputs are within ordinary physical / practice ranges)
TypeScript
Loading editor…
List of test cases (8)
Case 1
fahrenheit = 32
Case 2
fahrenheit = 212
Case 3
fahrenheit = -40
Case 4
fahrenheit = 98.6
Case 5
fahrenheit = 77
Case 6
fahrenheit = 0
Case 7
fahrenheit = 100
Case 8
fahrenheit = -459.67