numbers

PHP get largest number from 3 variables [duplicate]

落花浮王杯 提交于 2019-12-13 00:40:59
问题 This question already has an answer here : Closed 7 years ago . Possible Duplicate: Return variable with the highest value? I'm trying to come up with a simple way of finding the highest number out of 3 variables. $1 = 100 $2 = 300 $3 = 200 out of those 3 variables, I want to set a new variable as the highest one ($2) so: $highest_number = 300 回答1: $highest_number = max($1, $2, $3); OR $values = array($1, $2, $3); $highest_number = max($values); Additional information can be found at the

Relationship between integers and their names - Prolog

非 Y 不嫁゛ 提交于 2019-12-12 22:00:55
问题 I'm trying to explore the concepts of natural numbers, Peano numbers, arithmetic, etc. in Prolog. Right now I'm trying to create a predicate that will allow me to enter the name of any number and get it's numerical value (or vice versa). How would I go about this? My idea was that I would translate the numbers given and them add them together using the plus function (e.g. one hundred and forty-five: one, hundred = 100, and = 0, forty = 40, five = 5 -> 100 + 0 + 40 + 5 = 145. Here's an example

How to find the smallest closest number in a list in python

 ̄綄美尐妖づ 提交于 2019-12-12 19:21:19
问题 I want to know how can I find the smallest closest number in a list to a given number. For example: number = 20 list_of_numbers = [4, 9, 15, 25] I tried this: min(list_of_numbers, key=lambda x:abs(x-number)) The output is 25 and not 15. The problem is that it always gives me the "biggest closest" and not the "smallest closest". 回答1: You could make the key also contain the number itself and use that for breaking ties: min(list_of_numbers, key=lambda x: (abs(x - number), x)) Your behavior is

Jenkins and maven-buildnumber-plugin

ぃ、小莉子 提交于 2019-12-12 15:55:05
问题 I am using maven-buildnumber-plugin version 1.0-beta-4. This works fine on a project checked out of Subversion, but fails in Jenkins. I assume this problem is due to Jenkins somehow removing the .svn folders. I assumed wrong. Here is the error I got: maven builder waiting mavenExecutionResult exceptions not empty org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.codehaus.mojo:buildnumber-maven-plugin:1.0-beta-4:create (default) on project swift-core: Cannot

Create suffixed numbers Racket

被刻印的时光 ゝ 提交于 2019-12-12 14:55:26
问题 I'm trying to experiment with what I can do in Racket, and I want to suffix numbers with letters. For this example, I'd simply like to represent 10000 as 10K , and 1000000 as 1M . Is there way (with macros or otherwise) that I can expand 1M to: (* 1 1000000) Or something to that effect? 回答1: In Racket, things like 10K are identifiers , which normally would refer to variables. There are two ways to make them into numbers: 1: redefine what "undefined" identifiers mean You can redefine what to

Split data in sql with multiple delimiters ( , and - ) with owns rule

╄→гoц情女王★ 提交于 2019-12-12 14:46:11
问题 I have data like this 1,2,3,4-8,10,11 I want split the data into rows with these 2 rules : The , will only split the data into rows. Ex 1,2,3 become : 1 2 3 The - will split into series number. Ex 4-8 become : 4 5 6 7 8 How can a SQL query do that? Please answer and keep it simple. 回答1: This will work as long as your intervals are less than 2048 (let me know if that numbers can go higher) and you @data follow your current syntax: declare @data varchar(50) = '1,2,3,4-8,10,11' ;with x as (

Haskell: Couldn't expected type 'Integer' with actual type 'Int'

喜夏-厌秋 提交于 2019-12-12 13:35:16
问题 I've been staring at this code for quite some time now and I can't get my head around that error message. divisors :: Integer -> [Integer] divisors n = [t | t <- [1..n], mod n t == 0] length' :: [a] -> Integer length' [] = 0 length' (x:xs) = 1 + length' xs divLengths :: [(Integer, Integer)] divLengths = [(n, length' (divisors n)) | n <- [1..]] divLengths' :: [Integer] divLengths' = [length' (divisors n) | n <- [1..]] hcn :: [Integer] hcn = [n | n <- [1..], max (take n divLengths') == length'

Why does R regard large number as EVEN

感情迁移 提交于 2019-12-12 13:01:50
问题 From "http://cran.r-project.org/doc/FAQ/R-FAQ.html#Why-doesn_0027t-R-think-the" 7.31 We already know that large number (over 2^53) can make an error in modular operation. However, I cannot understand why all the large number is regarded as even(I have never seen "odd" of large integer which is over 2^53) even though I take some errors in approximation (2^53+1)%%2 (2^100-1)%%2 error message(probable complete loss of accuracy in modulus) can be ignored etc.. are all not 1 but 0 why so? (I know

Fast way to check if long integer is a cube (in Java)

会有一股神秘感。 提交于 2019-12-12 12:33:47
问题 I am writing a program in which I am required to check if certain large numbers (permutations of cubes) are cubic (equal to n^3 for some n). At the moment I simply use the method static boolean isCube(long input) { double cubeRoot = Math.pow(input,1.0/3.0); return Math.round(cubeRoot) == cubeRoot; } but this is very slow when working with large numbers (10+ digits). Is there a faster way to determine if integer numbers are cubes? 回答1: There are only 2^21 cubes that don't overflow a long (2^22

How to sum a list of numbers in python

痞子三分冷 提交于 2019-12-12 12:15:32
问题 So first of all, I need to extract the numbers from a range of 455,111,451, to 455,112,000. I could do this manually, there's only 50 numbers I need, but that's not the point. I tried to: for a in range(49999951,50000000): print +str(a) What should I do? 回答1: Use sum >>> sum(range(49999951,50000000)) 2449998775L It is a builtin function, Which means you don't need to import anything or do anything special to use it. you should always consult the documentation, or the tutorials before you come