Questions tagged [digits]

Questions dealing with getting, manipulating, or changing the digits of numbers

Use this tag for questions dealing with getting, manipulating, or changing the digits of numbers. More about digits on wikipedia

1098 questions
-4
votes
3 answers

Big numbers in Python

I am working in a problemas involving the e number . So I found this webpage which has 1000000 digits of the e number and I copy pasted to Python IDL. In the instant I pasted it froze and its still like that. I don't how long would it be or if it…
-4
votes
4 answers

Remove spaces between digits in a string

original: "I have the M5 2 0 0 and I like it" intended: "I have the M5200 and I like it" How would you achieve this as an algoritm or give a code example? I believe this question is valid in many programming languages so I won't ask it for a…
Adrian Cumpanasu
  • 1,028
  • 1
  • 10
  • 24
-4
votes
5 answers

Java: Check if a number is a double digit or single-digit no if statement?

I have homework to check if number is a double digit or a single-digit without using if statement. Thanks for your help! public class SchoolTest { public static void main(String[] args) { Scanner reader = new Scanner(System.in); …
user3819756
  • 27
  • 1
  • 2
  • 4
-5
votes
1 answer

How to generate a 14 digit serial number in python?

How can I generate 14 digit serial numbers in python where the last for 4 digit will be 0001 the next will be 0002 ...... 0011 and so on? This is how I want the format of the number to be 12101010010001 below is the breakdown of the format. First…
MyCDAR
  • 55
  • 7
-5
votes
1 answer

Python 3.4.4 Limiting to 2 digits isn't working (format(self.NUMBER, '.2f'))

I am trying to round a self.correct_answer = Smth. * Smth. I tried round(self.correct_answer, 2) and several different format(self.correct_answer, '.2f') type things. Is it because of the 'self.'? self.correct_answer = self.numbers1[self.number1] /…
-5
votes
2 answers

Why can't I correctly assign variables to an Array?

So I'm writing a program that inputs a number (binary) then assigns each digit of that input into an array. static void Main(string[] args) { Console.Write("Please enter a binary number: "); String input = Console.ReadLine(); int…
user3577478
  • 81
  • 1
  • 7
-5
votes
3 answers

c program to check digits in number are even

Input and Output Format: Input consists of a number which corresponds to the bill number. bill number is a 3-digit number and all the 3 digits in the number are even. Output consists of a string that is either 'yes' or 'no'. Output is yes when the…
-6
votes
1 answer

How to sort sum digits from the following list

list1 = [1236,985,150,641876,167] I want to know how to sorted by sum digits or sorted by last digit in Python. Output sorted by sum of digits in ascending order: [150,1236,167,985,641876]
-6
votes
2 answers

How can a Python string be a digit?

I was under the impression that numbers in double-quotation marks become strings. Why did I get the following result? "2001".isdigit() True
Josh Ossai
  • 17
  • 1
-6
votes
1 answer

How to count the number of different digits in a number?

This is a code that counts the number of digits in a number recursively. What can I add to this code to count how many different digits are in a number? Or maybe there is some other way? int numberOfDigits(int n) { if(n==0) return…
arani
  • 13
  • 7
-6
votes
3 answers

How do I reverse the order of only the digits in a string?

Given a string in Java, how can I obtain a new string where all adjacent sequences of digits are reversed? My code: import static java.lang.System.*; public class P2 { public static void main(String[] args) { if(args.length < 1) …
mackdiogo
  • 3
  • 1
  • 5
-6
votes
1 answer

n - 1 digits of a number

I have an 'n' digit number. I need to print the first n - 1 digits of the same. As far as I know, it is basically division by 10. But this is to be done without using any of the arithmetic operators. I tried using some of the conversions in ctype,…
user2053912
  • 173
  • 1
  • 3
  • 11
-6
votes
3 answers

How to print digit by digit of a number?

Possible Duplicate: Identify the digits in a given number. I need to print each digit of number without convert it to string. It's possible? For example: int n = 1234; int x; while( ?? ) { x = ?? printf("%d\n", x); } it prints:…
Jack
  • 16,276
  • 55
  • 159
  • 284
-7
votes
1 answer

Creating a number from digits stored in array using C

Now I have this number 193456787 stored in an array in C with each digit in a cell, how do I construct a four digit number from the digits in even numbered positions for example like 9468 ?
Omar
  • 3
  • 1
-7
votes
3 answers

How to sum the digits of a number using Recursion [C]?

For instance , the number is 123, the answer is 6. Only recursion!
1 2 3
73
74