Yeah, that'll work too. It's really the same as mine except that it uses only one array, replacing the other with a direct globbing loop.
A quick suggestion, though:
Regular array [index] fields operate in an arithmetic context, meaning you can do everything in them that you can do inside
((..)). You don't need '
$' in front of variables (except in complex cases), and you can do the post-incrementing there instead of afterwards. Just be sure not to add the increment operator until the last instance that uses the current value!
Setting
x=0 first isn't really necessary either. Uninitialized variables are treated as having a default value of zero when expanded in arithmetic contexts.
arithmetic expressions