nth fibonacci number in sublinear time
Is there any algorithm to compute the nth fibonacci number in sub linear time? ...
Is there any algorithm to compute the nth fibonacci number in sub linear time? ...
How can I generate a random whole number between two specified variables in Javascript, e.g. x=4 and y=8 would output any of 4,5,6,7,8? ...
I need a random number generator that picks numbers over a specified range with a programmable mean. For example, I need to pick numbers between 2 and 14 and I need the average of the random numbers to be 5. I use random number generators a lot. Usually I just need a uniform distribution. I don't even know what to call this type of di...
An error-free column name syntax is [My Column] instead of My Column which causes an error. An error-free string value syntax is '25,00' instead of 25,00 which causes an error. I'm getting an error using single quotes to enclose values, if the column data type is numeric. Are there any other ways to enclose values safely for string or ...
Hello everyone! I need to generate two numbers that are NOT equal in PHP. I know that I use $random1 = (rand()%9); to generate random a number between 0-9. I need to add something to this I guess. Thanks! ...
I have the following function that rounds a number to the nearest number ending with the digits of $nearest, and I was wondering if there is a more elegant way of doing the same. /** * Rounds the number to the nearest digit(s). * * @param int $number * @param int $nearest * @return int */ function roundNearest($number, $nearest, ...
I have a requirement to format large numbers like 4,316,000 as "4.3m". How can I do this in C#? ...
hi all I have a string with a number inside and I want to retrieve that number. for example if I have a string "bla bla 45 bla bla" I want to get the number 45. I have searched a bit and found out that this code should make the work Matcher matcher = Pattern.compile("\\d+").matcher("bla bla 45 bla bla"); if(matcher.matches()) String...
I have the following number: 4.3 I'd like to display this number as 4,3 for some of our European friends. I was under the impression that the following line would do the trick: string ret = string.Format("{0:0,0}", 4.3); // returns "04", not "4,3" Am I using the incorrect string? ...
I have an ordered list, but I want to number is manually in a separate span tag than use the default list-style: decimal; <ol> <li><span>1</span> item 1</li> <li><span>2</span> item 2</li> </ol> How can I achieve this using jQuery? Many thanks! ...
This is a CSE homework, I was hoping there might be some friendly guys and gals out there that might take a quick look and see if it looks good to turn in, thanks Y'all. Here are the instructions and the code I wrote, -Kyle write a ComplexNumber class with: (1) a constructor which does not take any parameters (where the defaul...
I'm not particularly knowledgeable about spreadsheet wrangling, so I could use some assitance with a seemingly simple problem. I have a column of year values which I am sorting by. I'd like to find the quantity per year ( read: number of repeats of each year value ). I'd like to chart said values. I'm not sure how to make this happen. I...
This seems like a stupid question. Is the number "10" refered to "10" in Hebrew, Arabic, and all languages? I'm not seeing anywhere where it says you need to do anything special with numbers when dealing with localization. Maybe number format but what about the number itself? I would think that numbers would read differently in right...
When i do (/ 411 125) , i dont get it in terms of decimal, how do I do that? ...
Removing everything after and including the decimal, and everything non-numerical except the dash if its in is the first character. So far I have this: /[^0-9^-]|[^\.]+$/. Notice How I block dashes from being removed with ^-, because somehow I want to only remove the dashes that aren't the first character (not the sign). Any help? Thanks...
I want to separate the digits of an integer, say 12345, into an array of bytes {1,2,3,4,5}, but I want the most performance effective way to do that, because my program does that millions of times. Any suggestions? Thanks. ...
I am trying to make a numerical value, say 5000, quickly change to another value, say 4000, using JQuery. Right now I do this fine using: mod(".class",4000,"add"); function mod(id,value,type){ var numb = $(id).html(); var current_value = parseInt(numb); do { if(type == "add") increment(id); else...
How can I create a regex expression which will match only letters and numbers, and one space between each word? Good Examples: Amazing Hello Beautiful World I am 13 years old Bad Examples: Hello world I am 13 years old. I am Chuck Norris ...
Can anyone please write or give me a link where I can find the C# code to list all the permutations for a give set of numbers in the most efficient manner? ...
i need to print out numbers 1-100 in a random order. the print statement should be: echo 'h{'.$num.'}'; what is the shortest code to do this? ...