Linked Questions

14 votes
3 answers
97k views

I have do detect the amount of digits on a number. For example, 329586 has 6 digits. What I done, is simply parsing the number to string, and getting the string length, like: number.toString()....
João Vitor Verona Biazibetti's user avatar
7 votes
4 answers
53k views

Given the following code. int[] eg = {21,20,1,12,2} public numbers(int[] eg) { for(int i=0; i < eg.length; i++) I would expect eg.length to be 5, where eg[0] would = 21 eg[1] would = 20, ...
30iT's user avatar
  • 125
-1 votes
3 answers
12k views

long AccountNumber = 1234567890; public void setAccNum(long Number) try(the size of the account number is lesser than equal to 10){ this.Accountnumber = Number; } catch(Exception e)...
Monisha Mohan's user avatar
2 votes
3 answers
4k views

I am creating a little trivial palindrome quiz in Java. I should at some point check if the user will enter more or less than a three digit number such as "1011" or "10" and display an error ...
m.rossi's user avatar
  • 2,662
0 votes
1 answer
639 views

I have a requirement where i need to find the number of digits in a integer. I have searched it and got some tricks. But i also developed a my own trick. I just want to know if it is correct way to ...
user3690370's user avatar
-1 votes
4 answers
158 views

How can I find the amount of digits in an integer? Mathematically, and by using functions if there are any. I don't really know how to do that, since I'm a somewhat beginner.
Michael Kashani's user avatar
4 votes
5 answers
254 views

e.g. for int n = 1234 I could create a string (s.valueOf(n)), then I would define the array like this: int[] array = new int[s.length()]; //this allocates memory for an array with 4 elements Is ...
constant's user avatar
  • 113
5 votes
4 answers
683 views

Given an infinite sequence like so (commas inserted to make pattern more apparent): 1, 1 2, 1 2 3, 1 2 3 4, 1 2 3 4 5, 1 2 3 4 5 6 ,1 2 3 4 5 6 7, 1 2 3 4 5 6 7 8, 1 2 3 4 5 6 7 8 9, 1 2 3 4 5 6 7 8 ...
Ogen's user avatar
  • 6,729
5 votes
6 answers
1k views

I need to find the number of heavy integers between two integers A and B, where A <= B at all times. An integer is considered heavy whenever the average of it's digit is larger than 7. For example:...
theJuls's user avatar
  • 7,580
1 vote
5 answers
2k views

I have to replicate the luhn algorithm in Java, the problem I face is how to implement this in an efficient and elegant way (not a requirement but that is what I want). The luhn-algorithm works like ...
Joop's user avatar
  • 3,818
0 votes
4 answers
2k views

I am looking for a way to dynamically set the size of an integer array depending on the passed parameter. For example this in pseudocode: int MyFunction(int number) { int myarr[amount of digits in ...
Dark Side's user avatar
  • 725
0 votes
5 answers
5k views

I need to write a program that accepts the following conditions: It has to be an odd number, Have an odd number of digits, All of its digits have to be odd numbers and The number has to be between ...
Dekart Kosa's user avatar
0 votes
3 answers
4k views

I want to know how we can find of length of Numeric field in sql. What will be the command / Query so that we can find length of perticular field in table. E.g.: For below table: Column1 Column2 1 ...
abhishek's user avatar
  • 355
1 vote
4 answers
626 views

I have a number like 601511616 If all number's length is multiple of 3, how can a split the number into an array without making a string Also, how can I count numbers in the int without making a ...
Asterisk's user avatar
-2 votes
7 answers
665 views

Is there any single line of code that can be used to calculate the number of digits in a program? I mean to say, can be there a reference to a class (such as String.length for a String) which can be ...
Niluu's user avatar
  • 9

15 30 50 per page