I'm supposed to generate random numbers using the mid square method. Initially, I have a 4-digit number which I'm supposed to square. Then I have to extract the middle digits.I square this again and extract the middle digits. The problem is, I don't always get 8 digits when I square it. I'm supposed to append zeroes to the left of the string to make it exactly 8 digits, but I don't know how to do it.
example:
8065 65044225
0442 195364
5364 28772496
As you can see, I'm supposed to get 1953 instead of 5364. I really don't know what to do, please help. thanks!
Bookmarks