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
-2
votes
2 answers

function that splits digits then sums them

I am trying to solve a problem that requires me to take a number. Use the % and / to take the rightmost number and sum the digits that are separated. Then tell see if the number is divisible by 9. I have created a function that will separate the…
Dre_04
  • 1
-2
votes
3 answers

How can I pass the selective part of fraction number to string for displaying?

I would like to display the first 4 digit of fraction number and pass it to string to display in title of my plot. I checked this post but I couldn't find an elegant way. I've tried following code as the easiest way the problem is I don't want to…
Mario
  • 1,631
  • 2
  • 21
  • 51
-2
votes
1 answer

Regex to check for total number of digits with a min and max

I want to test a string of all alphanumeric characters and return true only if the total number of digits in the string is between 7 and 11. 1234567 // true 11qqw3qd1221wqd2132 // true abc123def456ghi789klm012 //…
partypete25
  • 4,353
  • 1
  • 17
  • 16
-2
votes
2 answers

Sum of Digits in an Integer?

I'm working on an assignment in Python and don't understand the problem with my code. Based on other answers on Stack Overflow, the answer seems to be: def digit_sum(number): return (sum(int(digit) for digit in str(number))) Where as my code…
Kevin
  • 3
  • 2
-2
votes
3 answers

How to find a first occurrence of double digit number

So, I am pushing elements into array through prompt until getting 0. After that I am trying to find the first double digit number. For example if the array is [2,3,55,0] my program should return 55. function findFirstDouble() { var niz = [] …
-2
votes
1 answer

Reverse Integer in Endless Loops

Hey its OK to when i set value for integer but i dont want just reverse one i want reverse integer in a endless loop(infinite) so here is my code: #include int main() { int num = 2, preNum, digit; while (1) { while (num > 0) { …
-2
votes
3 answers

Check if number has its digits in order

I am trying to check if, given any number, its digits are in order. Example: 1479 -> TRUE 1293 -> FALSE Is there a proper way to do this in Haskell? I am new to the language and feel really lost at the moment. Thank you.
-2
votes
1 answer

Comparing two three-digits number

I got stuck in a game called 'strike or ball' IndexError came out. This has a very simple rule. If I put three digits whose type is 'str', it is being compared with another three digits made by 'random'. If they share only one digit and it's placed…
olorolor
  • 3
  • 3
-2
votes
1 answer

PHP string comparisons not producing the results I expect

I'm very VERY confused!! var_dump('12345678901234567891' == '12345678901234567890'); shows bool(true)! I know about "===" but in this example two strings (types are same)!!! Moreover strings are consists only of DIGITS! Any suggestions?
-2
votes
1 answer

Division by 0 in TurboPascal7

I am working on my school project and I am (almost) furious about this issue. My solution's validity is 95 %, but I have 1 input wrong – I don't know the input, but I know, that the input failed because of the error code 200, which is divison by…
user7625212
-2
votes
1 answer

Sign and 0 in front of double

I need some mechanism to count numbers from -178.125 through -1.875 and +000.000 to +180.000 with step 1.875 so it always has plus or minus sign in the front of the number and has three digits, then dot and then three digits again. The only thing…
Štěpán Šubík
  • 109
  • 2
  • 3
  • 10
-2
votes
1 answer

Determinate the number of significant digits

How can I determinate the number of significant digits of a double type number given by user. Thank you.
-2
votes
3 answers

Tips for cleaning up a challenge's answer? Weighted Sum of Digits

I've been going through some code challenges. And one struck me in particular. CodeAbbey has a Weighted Sum of Digits challenge. And this was my answer. # open and read a file, hardcoded numbers, etc. Here is a sample raw_data = (6, 19, 64, 6527226,…
-2
votes
2 answers

Java Array get digits and make number from array input

import java.util.Scanner; public class Tar0 { static Scanner in = new Scanner (System.in); public static void main(String[] args) { int d, i = 0, a = 0, f = 1; System.out.println("Enter How many Digits you want?"); d…
Damnsoul
  • 119
  • 1
  • 1
  • 4
-2
votes
2 answers

Create a c# programme that take digits as input from user and print it on words

whatever the input is it should print the answer in words(no limits) For example input is 2 it should answer in words "TWO" few more examples to understand 12 = "twelve" ,51 = "fifty one", 1000 = "One thousand",2005 = "two thousand and five" and so…