declaring long[] array in java declaring long[] array in java arrays arrays

declaring long[] array in java


Plain number is considered as int in java. Append L which are bigger than Integer.MAX_VALUE to convert long.

long[] powers = {..., 2863245995L, 11453115051L, ...};

According to docs

An integer literal is of type long if it is suffixed with an ASCII letter L or l (ell); otherwise it is of type int.

The suffix L is preferred, because the letter l (ell) is often hard to distinguish from the digit 1 (one).


Have you tried something like this?

long[] powers = { 0, 0, 1, 7, 35, 155, 651, 2667, 10795, 43435,            174251, 698027, 2794155, 11180715, 44731051, 178940587,            715795115L, 2863245995L, 11453115051L, 45812722347L, 183251413675L,            733006703275L, 2932028910251L, 11728119835307L, 46912487729835L,            187649967696555L, 750599904340651L, 3002399684471467L};