Skip to content
Advertisement

print numbers from 1 to 1000 digit number – interview question

I had an interview and I’ve been asked to print numbers from 1 to a 1000 digit number –

1, 2, 3, . . . ., 999999999999999999999999999999999999999999999999……..

I couldn’t solve it but I’m still looking for the best way to do it, because obviously, you cant use integers or floats in a case like this and because it’s a job interview I couldn’t use any libraries that can handle it.

Can anyone think of a good solution? preferably in Java/pseudocode.

Advertisement

Answer

Using recursion (if only to print):

JavaScript
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement