In reply to bachan21:
i think we can use hexadecimal format and shift operations to print this pattern
- take the input patterns like “3”,“5”,“7”,“9”,“11”,“13” …
- convert it to hex decimal numbers
longint value = str.atohex(); - using below logic we can get format(num = 0 )
for (int i = 1; i <= x; i++)
num = (num << no_of_bits) + value;
Note: number of bits to shift → no of bits needed to represent a input number in hexadecimal
if ( ip_value < 16 ) no_of_bits = 4;
else if ( (ip_value < 256) && ( ip_value >= 16)) no_of_bits = 8;
Hope it helps