# How to create geometric progression series in R?

A geometric progression series is a sequence of numbers in which all the numbers after the first can be found by multiplying the previous one by a fixed number. To generate a geometric progression series in R, we can use seq function. For example, to generate a geometric progression series of 2 by having the difference of multiplication value equal to 1 up to 5 can be found as 2^seq(0,5,by=1) and the output would be 1, 2, 4, 8, 16, 32.

## Examples

2^seq(0,5,by=1)
[1] 1 2 4 8 16 32
2^seq(0,5,by=2)
[1] 1 4 16
2^seq(0,10,by=1)
[1] 1 2 4 8 16 32 64 128 256 512 1024
2^seq(0,10,by=2)
[1] 1 4 16 64 256 1024
2^seq(0,20,by=1)
[1] 1 2 4 8 16 32 64 128 256
[10] 512 1024 2048 4096 8192 16384 32768 65536 131072
[19] 262144 524288 1048576
2^seq(0,20,by=2)
[1] 1 4 16 64 256 1024 4096 16384 65536
[10] 262144 1048576
2^seq(0,30,by=1)
[1] 1 2 4 8 16 32
[7] 64 128 256 512 1024 2048
[13] 4096 8192 16384 32768 65536 131072
[19] 262144 524288 1048576 2097152 4194304 8388608
[25] 16777216 33554432 67108864 134217728 268435456 536870912
[31] 1073741824
2^seq(0,30,by=2)
[1] 1 4 16 64 256 1024
[7] 4096 16384 65536 262144 1048576 4194304
[13] 16777216 67108864 268435456 1073741824
2^seq(0,30,by=5)
[1] 1 32 1024 32768 1048576 33554432 1073741824
2^seq(0,35,by=1)
[1] 1 2 4 8 16 32
[7] 64 128 256 512 1024 2048
[13] 4096 8192 16384 32768 65536 131072
[19] 262144 524288 1048576 2097152 4194304 8388608
[25] 16777216 33554432 67108864 134217728 268435456 536870912
[31] 1073741824 2147483648 4294967296 8589934592 17179869184 34359738368
2^seq(0,35,by=5)
[1] 1 32 1024 32768 1048576 33554432
[7] 1073741824 34359738368
2^seq(0,35,by=7)
[1] 1 128 16384 2097152 268435456 34359738368
2^seq(0,39,by=1)
[1] 1 2 4 8 16
[6] 32 64 128 256 512
[11] 1024 2048 4096 8192 16384
[16] 32768 65536 131072 262144 524288
[21] 1048576 2097152 4194304 8388608 16777216
[26] 33554432 67108864 134217728 268435456 536870912
[31] 1073741824 2147483648 4294967296 8589934592 17179869184
[36] 34359738368 68719476736 137438953472 274877906944 549755813888
2^seq(0,100,by=1)
[1] 1.000000e+00 2.000000e+00 4.000000e+00 8.000000e+00 1.600000e+01
[6] 3.200000e+01 6.400000e+01 1.280000e+02 2.560000e+02 5.120000e+02
[11] 1.024000e+03 2.048000e+03 4.096000e+03 8.192000e+03 1.638400e+04
[16] 3.276800e+04 6.553600e+04 1.310720e+05 2.621440e+05 5.242880e+05
[21] 1.048576e+06 2.097152e+06 4.194304e+06 8.388608e+06 1.677722e+07
[26] 3.355443e+07 6.710886e+07 1.342177e+08 2.684355e+08 5.368709e+08
[31] 1.073742e+09 2.147484e+09 4.294967e+09 8.589935e+09 1.717987e+10
[36] 3.435974e+10 6.871948e+10 1.374390e+11 2.748779e+11 5.497558e+11
[41] 1.099512e+12 2.199023e+12 4.398047e+12 8.796093e+12 1.759219e+13
[46] 3.518437e+13 7.036874e+13 1.407375e+14 2.814750e+14 5.629500e+14
[51] 1.125900e+15 2.251800e+15 4.503600e+15 9.007199e+15 1.801440e+16
[56] 3.602880e+16 7.205759e+16 1.441152e+17 2.882304e+17 5.764608e+17
[61] 1.152922e+18 2.305843e+18 4.611686e+18 9.223372e+18 1.844674e+19
[66] 3.689349e+19 7.378698e+19 1.475740e+20 2.951479e+20 5.902958e+20
[71] 1.180592e+21 2.361183e+21 4.722366e+21 9.444733e+21 1.888947e+22
[76] 3.777893e+22 7.555786e+22 1.511157e+23 3.022315e+23 6.044629e+23
[81] 1.208926e+24 2.417852e+24 4.835703e+24 9.671407e+24 1.934281e+25
[86] 3.868563e+25 7.737125e+25 1.547425e+26 3.094850e+26 6.189700e+26
[91] 1.237940e+27 2.475880e+27 4.951760e+27 9.903520e+27 1.980704e+28
[96] 3.961408e+28 7.922816e+28 1.584563e+29 3.169127e+29 6.338253e+29
[101] 1.267651e+30
2^seq(0,100,by=2)
[1] 1.000000e+00 4.000000e+00 1.600000e+01 6.400000e+01 2.560000e+02
[6] 1.024000e+03 4.096000e+03 1.638400e+04 6.553600e+04 2.621440e+05
[11] 1.048576e+06 4.194304e+06 1.677722e+07 6.710886e+07 2.684355e+08
[16] 1.073742e+09 4.294967e+09 1.717987e+10 6.871948e+10 2.748779e+11
[21] 1.099512e+12 4.398047e+12 1.759219e+13 7.036874e+13 2.814750e+14
[26] 1.125900e+15 4.503600e+15 1.801440e+16 7.205759e+16 2.882304e+17
[31] 1.152922e+18 4.611686e+18 1.844674e+19 7.378698e+19 2.951479e+20
[36] 1.180592e+21 4.722366e+21 1.888947e+22 7.555786e+22 3.022315e+23
[41] 1.208926e+24 4.835703e+24 1.934281e+25 7.737125e+25 3.094850e+26
[46] 1.237940e+27 4.951760e+27 1.980704e+28 7.922816e+28 3.169127e+29
[51] 1.267651e+30
2^seq(0,100,by=4)
[1] 1.000000e+00 1.600000e+01 2.560000e+02 4.096000e+03 6.553600e+04
[6] 1.048576e+06 1.677722e+07 2.684355e+08 4.294967e+09 6.871948e+10
[11] 1.099512e+12 1.759219e+13 2.814750e+14 4.503600e+15 7.205759e+16
[16] 1.152922e+18 1.844674e+19 2.951479e+20 4.722366e+21 7.555786e+22
[21] 1.208926e+24 1.934281e+25 3.094850e+26 4.951760e+27 7.922816e+28
[26] 1.267651e+30
2^seq(0,100,by=5)
[1] 1.000000e+00 3.200000e+01 1.024000e+03 3.276800e+04 1.048576e+06
[6] 3.355443e+07 1.073742e+09 3.435974e+10 1.099512e+12 3.518437e+13
[11] 1.125900e+15 3.602880e+16 1.152922e+18 3.689349e+19 1.180592e+21
[16] 3.777893e+22 1.208926e+24 3.868563e+25 1.237940e+27 3.961408e+28
[21] 1.267651e+30

Updated on: 07-Nov-2020

1K+ Views