I'd take a simple recursive approach, here with characters, but you could build your numbers using other means as well..
in C:
#include <stdio.h>
void keystrokes(int x, int lo, int hi, char array[]) {
int i;
if (x > hi)
return;
if (x >= lo) {
array[x] = 0;
printf ("%s\n", array);
}
for (i = 2; i < 10; i++) {
array[x] = i+'0';
keystrokes (x+1, lo, hi, array);
}
}
int main(void)
{
char array[33];
keystrokes(0, 2, 32, array);
return 0;
}
It can be optimized a bit (for example, for all 32-digit numbers, it'll still make 10 extra recursive calls), but it'll still take forever to compute all possible combinations.