What Is The Algorithm To Compute The Factorisation Of An Integer?
Oct 30, 2006
I need some ideas on how to compute the factorisation of a non-zero integer?
For example:
if the user input is 8, its factorisation is 1 * 2 * 2 * 2;
if the user input is -300, its factorisation is -1 * 2 * 2 * 3 * 5 * 5
Does anyone know?
View 3 Replies
ADVERTISEMENT
Jul 20, 2005
First script, 'xxx.js' returns value 'document.write('integer');
So in HTML:
<script language='javascript' src='xxx.js'></script>
will write ie. 123 on my page in browser.
Can I get this integer or text 'document.write('integer')' to variable in
another script? So it would be something like this:
<script landuage='javascript>
a=<script ... src='xxx.js'></script>;
a*=20;
document.write(a);
</script> ...
View 1 Replies
View Related
Sep 13, 2006
I am trying to learn how to do this one thing with JavaScript and can't seem to find anything on the internet. I have learned about loops and arrays and some other useful stuff. I've been looking for 2 days straight. I have gotten close though.
I am trying to have a textbox on the page and a button below it. A statement above the textbox should ask the user to enter a positive integer and then click the button. When the button is clicked the results from 0 to that number should appear below the button. Should look like this
please enter positive integer.
6
BUTTON1
1
2
3
4
5
6
I have been trying night and day for 2 days now and It's driving me insane.
View 8 Replies
View Related
Mar 23, 2009
I am working on implementing a carousel-style switcher (using a pre-built script dependent on the MooTools library) on the home page of one of my Web sites. The script displays a series of thumbnail images. When the user clicks on one of those thumbnails, an AJAX request returns the following items, which are then switched out using javascript:A background image (usually between 50 and 100 kilobytes)A foreground image (usually between 10 and 20 kilobytes)A header for the promotional item (strictly text)The body text of the promotional item (text and HTML code, generally no more than 200 characters of text)I have all of that working properly.
When the user clicks on the thumbnail, the AJAX function executes. Then, I use javascript to invoke a new Image() object to load the background image. Once that's completed, I invoke another Image() object to load the foreground image. Once both requests are fully loaded, I switch out the information. While they are working, I display an animated gif that indicates the information is loading. However, if at all possible, I would like to implement a progress indicator rather than just a simple animated gif. Because of the size of the background images, it can sometimes take between 10 and 15 seconds to load on a dial-up connection (even longer if the user's connection is especially slow or overloaded).
That's a long time to sit and stare at a "loading" image, especially if there's no way to indicate whether it's going to actually do anything or if it's just completely stalled. I am already sending the filesize of the background image and the foreground image to my javascript using the AJAX request, so if I need to use that somewhere in my script, I can easily do that. However, I've hit a roadblock in trying to figure out if there's a way to determine how much the user has actually downloaded successfully. From most of my research, it does not seem possible (due to security issues) to determine any sort of file size on the user's local computer using javascript.
However, the majority of the information I've found on the subject seems to relate to the opposite type of situation (users uploading files rather than downloading). The few examples I've been able to find for "download indicators" seem to simply count the total number of images being loaded, then divide 100 by that count. Then, for each image that loads, it adds that percentage to the indicator. Since I will always be loading two images, that means that my download indicator would always display 0%, 50% or 100%, which isn't much more helpful than the animated "loading" gif I'm already using. Is there any way to use javascript to determine how much (percentage-wise or in bytes) of a file a user has downloaded from the server into their cache?
View 4 Replies
View Related
Dec 7, 2011
When I click the compute button, it does not do anything. It does not go to function CALCULATE and do its stuff.
[Code]...
View 11 Replies
View Related
Jun 15, 2009
I have an application that resizes itself upon window resize. Theproblem is that if I resize down the window so it is smaller, twoscrollbars appear during resize (nothing new for now...), but thecomputed body width is the width with the scrollbars.Then, when I stop resizing, my app resizes itself, but as you may haveguessed, there are a small empty space on right and bottom,corresponding to the scrollbars.I have not found a pretty way to do it (of course I could set a timerinside my resize function that will call itself again 10ms later, just
View 2 Replies
View Related
May 6, 2005
i am trying to store some shopping cart details in a cookie. I have been able to do that but i want to now retrieve the values and put them in a shopping cart table. An example of the cookie file is
Product1=value,Quantity1=value,Price1=value,Extras1=value;
Product2=value,Quantity2=value,Price2=value,Extras2=value;
I have been able to retrieve the 2 cookies
cookieArray = document.cookie.split("; ")
for(i=0; i<cookieArray.length ; i++)
{
document.write(cookieArray[i] +"<br>")
}
But now for each Product i want to retrieve the 4 values. Can anyoine help me with this or suggest a better way to achieve the same thing.
View 7 Replies
View Related
Oct 20, 2009
I want obsfucate and compress the code for my website (HTML, CSS but especially Javascript). Are there any industry standard algorithms that are recommended?
View 5 Replies
View Related
Aug 16, 2010
I've written a function that "condenses" a string if it is too long.
function shortenMsg(msg,maxLen){
if (msg.length > maxLen){
var over = msg.length - maxLen, // amount that needs to be trimmed
[Code]....
Each of the methods 1-3 is the amount that that specific method can trim from the string. I'd like to be able to trim as little as possible.
For example, if the string needs 5 characters to be trimmed, and method1 can trim 8 characters, but method3 can trim 6, then method3 should be used. If none of the methods can individually trim the string enough, then I'd like the optimal combination of the methods that will get the job done.
I can't figure out what sort of code structure I need for this (besides a ton of if/else statements). Maybe an array that contains each of the methods, arranged in increasing order....?
View 10 Replies
View Related
Nov 2, 2004
Does anybody know of an algorithm to calculate mortgage payments? e.g.
Amount: 100,000
Interest Rate: 4.5%
Term: 25 Years
Monthly Payments: x
I've looked at other js scripts to do this but it seems alot more involved then I thought, and because they use non descriptive variable names I can't work any of them out..
View 1 Replies
View Related
Jan 19, 2010
I recently started on an browser based MMORPG, I just found 1 major issue.I'm using these libraries
JS A* Algoritm ( http://devpro.it/code/137.html )
Jquery ( http://www.jquery.com/ )
Jquery UI (http://ui.jquery.com/ )
So I'm using a little piece of JavaScript code in which im accessing the AStar function. The downside is, the AStar algorithm only finds vertical tiles. (See screenshots below)
function mapmouse (obj) {
//Get the coordinates
coords = obj.id.split('_');
[code]....
If you choose a non-vertical path, var path gives an empty array (path.length = 0 )If I choose a vertical path, it's working as intended.
As you can see with this little test here, the AStar function itself is working properly (the libs.js is used by both the game and the example)[URL]
View 1 Replies
View Related
Dec 5, 2011
I have an assignment to code a java class that plays rock, paper, or scissors. The class can access the history of past gestures played by both itself and its opponent, but nothing else. The class will be played against others in 10,000 matches and the winner will be determined via round robin format. Other than using a greedy algorithm to determine statistically the best choice from prior gestures and basic pattern recognition I have no decent ideas.
View 6 Replies
View Related
Jul 23, 2005
What is the best way to validate a field as a positive or negative
integer?
View 9 Replies
View Related
Sep 25, 2007
function calculateGst(exGst) {
//percentage of current gst.
var gst = 10;
var gstAmount = (exGst * (1 / gst));
var gstInc = (exGst + gstAmount)
alert(gstAmount);
alert(gstInc);
}
now, the exGst parameter comes from an document.getElemenetById('txtExGst').value in an onclick event.
the problem is this. if 400 is entered at exGst, the gstAmount spits out 40, as it should, but the gstInc spits out 40040...so its treating it like a string rather than a number...
View 4 Replies
View Related
Jan 29, 2006
how can i convert an integer value into related character. is there any function for it?
View 2 Replies
View Related
Jun 17, 2010
i need to do some arithmetic on the returned value from:
var left = $('.object').css('left');
it comes back as px value, but i need just the number.
View 3 Replies
View Related
Sep 28, 2009
I'm little struggling with the following. How can you create the following integers?
1000000 -> 1.000.000
50000 -> 50.000
100 -> 100
Is there a native JS function to accomplish this?
View 2 Replies
View Related
Feb 20, 2006
How can I verify a text input box has an integer value and that value is greater than 0?
View 1 Replies
View Related
Sep 3, 2009
function load(cv)
{
setInterval("checknew('cv')",1000);
}
checknew sends the number 1 or 0 depending on what load sends, and in turn, its just alternating 1/0 every second.
I am unsure how to send the number I get in load(cv) to checknew(cv) every 1 second on setInterval.
View 3 Replies
View Related
Jun 14, 2010
I have some one page whose div elements are aligned by JavaScript. The JavaScript just check a set of div elements to find the max offsetWidth, then set all div elements' width to be the max offsetWidth. It works perfect in most browsers and locales, but it fails on french-France in Firefox on Mac. In this case, the content of div wraps.
<div id="divFoo">
Heure de début :
</div>
for above HTML, below code report "79".
javascript:alert(document.getElementById('divFoo').offsetWidth);
but below code report "79.1333px".
javascript:alert(window.getComputedStyle(document.getElementById('divFoo'),null).width))
The gap between 79.1333 and 79 makes incorrect width set to inline style.I used to thought that offsetWidth and width should always be integer. Is there any way to make offsetWidth round correctly?
View 3 Replies
View Related
Nov 30, 2010
I want javascript function that could convert from integer to float e.g if user enters 10 then it should convert it to 10.00 or better 10.000. If user enters 10.0123 then it should convert it to 10.0123.
View 1 Replies
View Related
Aug 16, 2011
I have the following Javascript code to make a simple calculation. It works fine the numbers entered are integer. But if the numbers are 1.5 style I get stupid results or NAN error. I would like to add a check to the script which checks:
1- If the value entered is integer or 1.5 style for all fields. If it is not gives an alert message and stop calculating.
2- If the visitor enters 1,5 instead of 1.5 (In Turkey it is a common usage.) I need script replace the 1,5 with 1.5 and then make the calculation
[Code] .....
View 2 Replies
View Related
Jul 20, 2005
I want to turn the string "100,144" to numbers, to use for
resizeTo(100,144) <--- here.
View 5 Replies
View Related
Jan 12, 2010
Is there a way to retrieve and store the value of obj.style.top as an integer instead of a string? Write now I'm limited to statements such as
if(obj.style.top=="98px")
View 1 Replies
View Related
May 6, 2010
Does JavaScript have an easy of converting an ordinary integer like 135 into a time format like 02:15? I'm working on a timer that handles the backend with just a plain integer that counts down every second but it needs to output looking like a clock.
View 5 Replies
View Related
May 12, 2010
I am pulling a value via JavaScript from a textbox.If the textbox is empty, it returns NaN.I want to return an empty string if it's null, empty,etc.What check do I do?if(NAN = tb.value) ?
View 8 Replies
View Related