Interesting numbers
Here's some interesting numbers. They're not necessarily "interesting", but there's some useful qualities about them, especially for programmers.
Minimum divisible by all
These numbers are divisible by X and all whole numbers below it. For example the number 2520 is divisible by 10, 9, 8, 7, 6, 5, 4, 3, and 2.
Note: only the minimum values are listed, for example 24 is divisible by 4, 3, and 2, but it's redundant because 12 is divisible by the same numbers.
| # | Divisible by | Notes |
|---|---|---|
| 2 | <= 2 | |
| 6 | <= 3 | |
| 12 | <= 4 | |
| 60 | <= 6 | fits into i8, u8 |
| 420 | <= 7 | |
| 840 | <= 8 | |
| 2520 | <= 10 | |
| 27,720 | <= 12 | fits into i16, u16 |
| 360,360 | <= 15 | |
| 720,720 | <= 16 | |
| 12,252,240 | <= 18 | fits into float |
| 232,792,560 | <= 22 | fits into i32, u32 |
| 5,354,228,880 | <= 24 | |
| 26,771,144,400 | <= 26 | |
| 80,313,433,200 | <= 28 | |
| 2,329,089,562,800 | <= 30 | |
| 72,201,776,446,800 | <= 31 | |
| 144,403,552,893,600 | <= 36 | |
| 5,342,931,457,063,200 | <= 40 | fits into double |
| 219,060,189,739,591,200 | <= 42 | fits into i64 |
| 9,419,588,158,802,421,600 | <= 46 | fits into u64 |
Code used to generate this list
u64 latest = 2;
u64 maxcount = 0;
for (u64 i=2; i; i+=latest) {
u64 count = 0;
for (u64 x=2; !(i%x); x++) {
count = x;
}
if (count > maxcount) {
maxcount = count;
latest = i;
printf("%llu is divisible by <= %llu\n", i, count);
}
if (i < latest) break; // i overflowed
}
Power of 2
"Power of 2" basically means any number created with 2ˣ, also known as 2^x, also known as pow(2,x). Replace x with any number.
One use is that they represent the value range of a given number of bits. For example 4 bits (2^4) can represent 16 different values; 0 to 15.
| # | Power | Notes |
|---|---|---|
| 2 | 2^1 | |
| 4 | 2^2 | |
| 8 | 2^3 | |
| 16 | 2^4 | |
| 32 | 2^5 | |
| 64 | 2^6 | |
| 128 | 2^7 | signed 8-bit integer range (-128 - 127) |
| 256 | 2^8 | unsigned 8-bit integer range (0 - 255) |
| 512 | 2^9 | |
| 1,024 | 2^10 | |
| 2,048 | 2^11 | |
| 4,096 | 2^12 | |
| 8,192 | 2^13 | |
| 16,384 | 2^14 | |
| 32,768 | 2^15 | signed 16-bit integer range (-32,768 - 32,767) |
| 65,536 | 2^16 | unsigned 16-bit integer range (0 - 65,535) |
| 131,072 | 2^17 | |
| 262,144 | 2^18 | |
| 524,288 | 2^19 | |
| 1,048,576 | 2^20 | |
| 2,097,152 | 2^21 | |
| 4,194,304 | 2^22 | |
| 8,388,608 | 2^23 | |
| 16,777,216 | 2^24 | float can store integers up to here (-16,777,216 - 16,777,216) |
| 33,554,432 | 2^25 | |
| 67,108,864 | 2^26 | |
| 134,217,728 | 2^27 | |
| 268,435,456 | 2^28 | |
| 536,870,912 | 2^29 | |
| 1,073,741,824 | 2^30 | |
| 2,147,483,648 | 2^31 | signed 32-bit integer range (-2,147,483,648 - 2,147,483,647) |
| 4,294,967,296 | 2^32 | unsigned 32-bit integer range (0 - 4,294,967,295) |
| 8,589,934,592 | 2^33 | |
| 17,179,869,184 | 2^34 | |
| 34,359,738,368 | 2^35 | |
| 68,719,476,736 | 2^36 | |
| 137,438,953,472 | 2^37 | |
| 274,877,906,944 | 2^38 | |
| 549,755,813,888 | 2^39 | |
| 1,099,511,627,776 | 2^40 | |
| 2,199,023,255,552 | 2^41 | |
| 4,398,046,511,104 | 2^42 | |
| 8,796,093,022,208 | 2^43 | |
| 17,592,186,044,416 | 2^44 | |
| 35,184,372,088,832 | 2^45 | |
| 70,368,744,177,664 | 2^46 | |
| 140,737,488,355,328 | 2^47 | |
| 281,474,976,710,656 | 2^48 | |
| 562,949,953,421,312 | 2^49 | |
| 1,125,899,906,842,624 | 2^50 | |
| 2,251,799,813,685,248 | 2^51 | |
| 4,503,599,627,370,496 | 2^52 | |
| 9,007,199,254,740,992 | 2^53 | double can store integers somewhere up to here |
| 18,014,398,509,481,984 | 2^54 | |
| 36,028,797,018,963,968 | 2^55 | |
| 72,057,594,037,927,936 | 2^56 | |
| 144,115,188,075,855,872 | 2^57 | |
| 288,230,376,151,711,744 | 2^58 | |
| 576,460,752,303,423,488 | 2^59 | |
| 1,152,921,504,606,846,976 | 2^60 | |
| 2,305,843,009,213,693,952 | 2^61 | |
| 4,611,686,018,427,387,904 | 2^62 | |
| 9,223,372,036,854,775,808 | 2^63 | signed 64-bit integer range (-9,223,372,036,854,775,808 - 9,223,372,036,854,775,807) |
| 18,446,744,073,709,551,616 | 2^64 | unsigned 64-bit integer range (0 - 18,446,744,073,709,551,615) |
| 340,282,366,920,938,463,463,374,607,431,768,211,455 | 2^128 | u128 |
Code used to generate this list
int power = 0;
u64 x = 1;
while (1) {
power ++;
x *= 2;
printf("2^%i = %llu\n", power, x);
if (x == 0) break; // x overflowed
}
printf("2^64 = %llu + 1\n", (u64)(U64_MAX));