GCD and LCM Calculator
Calculate GCD (greatest common divisor) and LCM (least common multiple) of two numbers. Free online calculator.
Enter a number and select its input base (binary, octal, decimal or hexadecimal). The calculator instantly converts the value to all four number systems. An essential tool for developers, computer science and electronics students.
Each digit in base b represents a power of b. To convert to decimal: sum each digit × b^position. To convert from decimal: divide repeatedly by the target base and read the remainders from last to first. The calculator uses JavaScript's parseInt and toString methods.
Decimal 255: input base = 10, value = 255. Results: binary = 11111111, octal = 377, hexadecimal = FF. Enter FF with base 16 to get the same values in reverse.
A number system is a set of symbols and rules for writing numbers. The most common is decimal (base 10). Binary (2), octal (8) and hexadecimal (16) are widely used in computing.
Binary uses only 0 and 1. Each position represents a power of 2 (from right: 2â°, 2¹, 2², …). Example: 1010â‚‚ = 0×1 + 1×2 + 0×4 + 1×8 = 10.
Hex uses digits 0–9 and letters A–F (A=10 … F=15). One byte (8 bits) = exactly two hex digits, so hex gives a compact way to write binary data. Example: 255â‚â‚€ = FFâ‚₆.
To convert any base to decimal: multiply each digit by the corresponding power of the base and sum. To convert decimal to another base: divide repeatedly by the target base and collect remainders.
Octal (base 8) uses digits 0–7. Each octal digit equals exactly 3 binary bits. Example: 377₈ = 011 111 111â‚‚ = 255â‚â‚€.
Divide the decimal number by 2 and record remainders. Read remainders from last to first. Example: 13 → 1101₂.
A byte is 8 bits (binary digits) and stores values 0–255 (00000000â‚‚ to 11111111â‚‚), equivalent to two hex digits (00â‚₆ to FFâ‚₆).
#RRGGBB encodes red, green and blue components as pairs of hex digits (00–FF, i.e. 0–255 decimal). Example: #FF0000 = pure red.
Electronic components (transistors) have two stable states: on (1) and off (0). Binary representation is noise-resistant and supports logical and arithmetic operations with simple circuits.
In memory addresses (hex), bitmasks and flags (bin/hex), colour coding (hex), network protocols (MAC and IP addresses in hex), microcontroller programming and binary data debugging.
Results are indicative. The calculator handles integers — fractional numbers may produce imprecise results.
Calculate GCD (greatest common divisor) and LCM (least common multiple) of two numbers. Free online calculator.