"speed Up" Prime # Test Script With These Modifi?
Nov 15, 2011
I have this code for figuring out whether a given number is prime or not:
var SMALLEST = 2;
var BIGGEST = 9E15;
var n = prompt("Enter a number and I'll check if it is prime");
if (isNaN(n) || n < SMALLEST || n > BIGGEST || n % 1 !== 0) {
alert("I can only test integers between " + SMALLEST + " and " + BIGGEST);
[Code]...
View 2 Replies
ADVERTISEMENT
Jun 20, 2011
i have a a script for typing speed test. after 10 sex. script shows some result like Raw CPM: 35 Corrected CPM: 20 WPM: 4Time left: 0 Your score: 20 CPM (that is 4 WPM) In reality, you typed 35 CPM, but you made 3 mistakes (out of 7 words), which were not counted in the corrected CPM score.
[Code]..
View 2 Replies
View Related
Apr 8, 2006
I'm not too experienced in programming, all I know is from practicing so don't be surprised if I made some mistakes. One mistake that I know is that the page is absolutely non-standard, but I don't really care about things like web-standards when making these little scripts.
As I'm Hungarian and not English, this code (functions, vars) was also written in Hungarian, but I translated it to be a bit more readable for Englishpeople. If it's still not clear, I can comment it.
<style>
body{text-align:center; font-family:arial;}
.answerbox,.detailbox {
background-color:#FFFFFF;
font-size:80;
height:100;
color: black;
font-weight:bold;
text-align: center;
width:950;
}
.detailbox {
height:80;
font-size:50
}
sup {font-size:40; vertical-align:top; position:relative; top:-5}
#quest{
font-size:20;
text-align:right;
border-style: solid;
border-color: gray;
border-width: 1;
width: 130
}
</style>
<script>
function power(arr)
{
newarr=new Array()
for(k=0; true; k++)
{
base=arr[0]
for (expo=1; arr[expo]==base;expo++){}
newarr[k]=base+(expo!=1 ? "<sup>"+expo+"</sup>" : "")
if (expo>=arr.length) {break}
arr=arr.slice(expo)
}
return newarr.join("×")
}
function twodivisors(numb)
{
for (var i=2; i<=Math.sqrt(numb); i+=1)
{
if (numb%i==0) {return new Array(i,numb/i)}
}
return "pr"
}
function analyze(num)
{
iffalse=detailsplace+"=num+'='+power(primedivisors);"+yesnoplace+"='Number '+num+' is not prime'"
iftrue=yesnoplace+"='Number '+num+' is prime'"+detailsplace+"=''"
if (num<2) {eval(detailsplace+"=''"+yesnoplace+"='Number '+num+' is not prime'"); return}
if (num==2) {eval(iftrue); return}
if (num%2==0)
{
primedivisors=new Array()
primedivisors.push(2)
for (otherdivisor=num/2; twodivisors(otherdivisor)!="pr"; otherdivisor=twoparts[1])
{
twoparts=twodivisors(otherdivisor);
primedivisors.push(twoparts[0]);
}
primedivisors.push(otherdivisor)
eval(iffalse); return
}
for (var i=3; i<=Math.sqrt(num); i+=2)
{
if (num%i==0)
{
primedivisors=new Array()
primedivisors.push(i)
for (otherdivisor=num/i; twodivisors(otherdivisor)!="pr"; otherdivisor=twoparts[1])
{
twoparts=twodivisors(otherdivisor);
primedivisors.push(twoparts[0]);
}
primedivisors.push(otherdivisor)
eval(iffalse); return
}
}
eval(iftrue); return
}
function starter()
{
num=document.formh.quest.value
if (isNaN(num)) {alert("You entered an invalid number."); return}
detailsplace="document.getElementById('details').innerHTML"
yesnoplace="document.getElementById('answer').innerHTML"
analyze(eval(num))
}
</script>
<div class=answerbox id=answer></div>
<div class=detailbox id=details></div>
<form name=formh>
Number: <input type=text id=quest><br>
<input type=button value="Is it prime?" onClick=starter()><br>
</form>
View 2 Replies
View Related
Mar 14, 2009
I'm using the standard module pattern and the problem is once you set a private variable, trying to test that object independently becomes a nightmare as the next test is polluted by the actions of the previous.So, the options are to have some reset method (which is horrible), setters on everything (defeats the point) or delete object and re-load script (hideous).
View 2 Replies
View Related
Jan 26, 2011
I can't seem to get past my function writing
<table rows='10 cols='10' border='1'><tr><th>Prime Numbers(1-100)</th></tr>
<!DOCTYPE HTML PUBLIC "-W3CDTD HTML 4.01EN" "[URL]">
<html>
<head>
<script type="text/javascript">
function primeNumbers() {
var tableCell = 0;
document.write("<table cols='10' border='1'>");
document.write("<tr>"); .....
View 4 Replies
View Related
Jun 23, 2011
So I wrote this piece of code, which should display the first 10,001 prime numbers.
Code:
<html><head>
<title>Problem 7 project euler</title>
</head><body><script>
var x = 3;
var primes = new Array();
primes[1] = 2;
var n = 1;
document.write("PRIME#1= 2" + "<br />")
while (n < 10001){
if (x%primes[n] == 0){
x = x + 2;
}else if ((n + 1) < (primes.length)){
n = n + 1
}else{
primes[(n+1)] = x;
document.write("PRIME#" + (n + 1) + "= " + primes[(n+1)] + "<br />");
x = x + 2;
n = 1
}}
</script>
</body>
</html>
Now the problem is that somehow this code also interprets some non-primes as primes.
View 7 Replies
View Related
Mar 22, 2010
HAVE CLIENT-SIDE FORM COOKIE GET AND SET FUNCTIONS IN THE SECOND WINDOW DOCUMENT EXTERNAL JS.FILE OF A DUMY TEST SITE FOLDER ON MYCOMPUTER. IE8 THROWS 'SYNTAX ERROR' ON THE 'WINDOW.LOAD=FUNCTION, FIRST COOKIE FUNCTION HIGHLIGHTED'. CAN I ACTUALLY TEST COOKIES ON A TEST SITE ON MY COMPUTER WITHOUT THE SERVER (MYCOMPUTER) OR A DOMAIN NAME? YEAH NO HECKLING FROM THE PEANUT GALLERY.[code]...
View 9 Replies
View Related
Jan 27, 2009
I am taking a javascript class and I need a script that displays the first 1000 prime numbers in a table with 10 numbers per row. I've been trying on my own for about 4 hours now and am really confused. I just started the class and have only started learning javascript 3 days ago.
View 6 Replies
View Related
Aug 29, 2011
here when i click the test button it will create a new test button inside div tag.But after that if i clicked new generated test button document.getElementById("test" ).onclick = function() is not working.how can i add functions to new dynamically created fields?
<div id="a" >
</div>
<input type="button" value="Test" id="test" class="form-submit"/>
when i click the test button it will create a new test button inside div tag
View 4 Replies
View Related
Oct 4, 2010
The .find() method does not seem to match on input fields by using a class. The ti This problem seems to be only visible on input fields. The following is a demonstration of the issue:
Example at [url]
View 2 Replies
View Related
Jul 23, 2005
I would like to design a page that measures the user's download
connection. Does anyone have an example link or script that might aid
me in this task?
View 4 Replies
View Related
Jul 23, 2005
anyway to check connection speed?
View 3 Replies
View Related
Aug 31, 2006
In the Yahoo! UI event.js file I see the following quite a bit
for (var i=0,len=unloadListeners.length; i<len; ++i) {
when I always just write
for (var i=0; i<unloadListeners.length; ++i) {
Is it worth it to declare the variable len to save time evaluating
unloadListeners.length?
View 14 Replies
View Related
Oct 16, 2007
Ive been having a problem of late with one of my sites that uses PHP5 /
Ajax. The problem is that periodically the ajax functions lock up and it
gets stuck in the loading phase of the request. If i restart the apache
server everything goes back to normal (i assume it severs the connection
to the ajax called function).
I think this is a problem with the javascript part as i have tried it
using a straight post request and have have no problems and slow loading
time is localized to the one user (ie. still works fine on the other
computers on my office network).
I have recorded this happening in Firefox, safari and IE6 & 7
My server is running debian with apache2 and php5
Just wondering if somebody can shed some light on what my problem may be? Code:
View 3 Replies
View Related
Apr 6, 2010
I've got the following site that loads great in FF and Chrome (no surprise), but is terribly slow in IE7. It's even quick in IE6, but not 7. Here's the site code...
Now I'm using JQuery in a couple places, but it's by no means nothing crazy. The page is fairly simple.
I thought of preloading the main content images, but even after they are loaded in the cycle, the loading time is still slow.
View 10 Replies
View Related
May 21, 2011
I read somewhere that putting Javascript code after CSS code on webpages makes them feel like they load faster. I was wondering if any of you has any experience with this and if you do follow this rule in your projects.
View 5 Replies
View Related
Sep 30, 2000
Just wondering if anyone knew if there was a definite speed advantage to VBScipt as opposed to JavaScript?
View 7 Replies
View Related
Apr 5, 2010
Why does the speed not permanently change?
<SCRIPT>
<!--
function ScrollMarquee(speed) {
var speednow = "";
speednow = speed;
window.setTimeout('ScrollMarquee('+speednow+')',speednow);
[Code]...
View 7 Replies
View Related
Feb 6, 2009
I wonder javascript execution speed depends on what ?
Meanwhile, if a flash slide show vs flash-like javascript slide show, which one will win due to download speed and execution speed?
View 2 Replies
View Related
Jul 23, 2005
I have to move 2 layers (one from up to center and one from bottom to
center) and I found this way:
<div id="up" style="position:absolute;left:10px;top:-20px">Up</div>
<div id="down" style="position:absolute;left:10px;top:200px">Down</div>
function movediv(){
var u = document.getElementById("up")
var d = document.getElementById("down")
u.style.top = "100px";
d.style.top = "100px";
}
It doesn' work...because:
1) They don't move at "the same time"...I would like to obtain
simultaneous move.
2) I can't control speed so moving is invisible!
View 8 Replies
View Related
Jul 20, 2005
I'm using the following to allow dynamic resixing of an image (when the usre
presses down on a button):
function widthup() {
image.width = image.width + 1;
width.innerText = image.width;
if(x==1) {
setTimeout('widthup()',0);
}
}
even when the 'setTimout' is at zero it goes pretty slowly. Any way to have
something faster?
View 3 Replies
View Related
Jun 22, 2011
It's possible to set custom speed for each pic or for some pics?and How remove the frame
View 4 Replies
View Related
Oct 31, 2011
I am new at this jquery stuff. In fact, I'm more of a cut and paste kind of gal I have a web page that I incorporated a slideshow. The picture seems to change a bit faster than I'd like, and I can't seem to make the picture go slower than it already is. Can anyone tell me what value I need to change to accomplish this? I changed a couple numbers, but didn't seem to have an affect. Also, is there a way to add a pause and play button so if the fading picture bothers someone, they can pause it?
[Code]...
View 3 Replies
View Related
Feb 2, 2010
Suppose I want to populate a drop down ajaxly. The population is written like:
var $select = $("#target");
$.each(datas, function(){
$("<option/>")
.val(thia.value).html(this.name)
.appendTo($select)
.data('srcData', this);
});
But the speed is considerably slow when the datas is large. I know that I can use just string concatenation and html() finally to speed it up but what can I do with the data()?
View 10 Replies
View Related
Jul 28, 2009
I'm trying to create a button that will increase and decrease the var speed variable
ex:
View 2 Replies
View Related
Nov 12, 2010
I'm justing wondering about the behavior of JS in regards to adding elements, suppose I have something like this:
I'm just wondering at the point I hit that "// DO SOMETHING WITH ONE OF THESE DIVS", are all the divs I have added in the DOM available to access?
I ask because I have some code at work in which a tester is reporting an error that happens which I can't reproduce, and they and others have had it a few times.
The only way I can explain it in my mind is if the div is not available to me at the time of execution. So I'm just looking to rule it out or confirm my hunch.
Is document.getElementById("myDiv").appendChild(obj); synchronous and the next line of code wont execute until the DOM is ready or is it in fact a asynchronous call and therefore adding alot of elements to the DOM could result in a lag so some divs or not available straight away.
View 1 Replies
View Related