Wikipedia:Reference desk/Archives/Computing/2008 October 25

From Wikipedia, the free encyclopedia
Computing desk
< October 24 << Sep | October | Nov >> October 26 >
Welcome to the Wikipedia Computing Reference Desk Archives
The page you are currently viewing is an archive page. While you can leave answers for any questions shown below, please ask new questions on one of the current reference desk pages.


October 25[edit]

There is any computer program that finds the Least common multiple and Greatest common divisor???[edit]

There is any computer program that finds the Least common multiple and Greatest common divisor of a set of numbers??? 201.79.105.113 (talk) 03:18, 25 October 2008 (UTC)[reply]

Writing one wouldn't be too hard. --67.54.224.199 (talk) 03:31, 25 October 2008 (UTC)[reply]
In Python this should work (assuming x,y are integers):
def gcd(x,y):
    while y:
        x,y = y, x%y
    return x
def lcm(x,y):
    return x*y/gcd(x,y)
but I haven't tested these. —Tamfang (talk) 06:26, 25 October 2008 (UTC)[reply]
They work. And the first one proves that Python is amazing. « Aaron Rotenberg « Talk « 09:46, 25 October 2008 (UTC)[reply]
It's almost as pretty in any other language (that has the mod operator), I imagine. —Tamfang (talk) 03:38, 27 October 2008 (UTC)[reply]

I want one that i am able to use any numbers of intergers that I want and not just 2. Is I wanted just 2 there is websites that do that. —Preceding unsigned comment added by 201.79.105.113 (talk) 15:34, 25 October 2008 (UTC)[reply]

Do it two at a time: gcd(a, b, c, d, e) = gcd(a, gcd(b, gcd(c, gcd(d, e)))), and the same goes for lcm() too. —Ilmari Karonen (talk) 16:15, 25 October 2008 (UTC)[reply]
For gcd, it's clearly most efficient to start with the smallest inputs, if you have a choice. For lcm, I'm not sure; depends on the algo; I wouldn't be surprised to learn there's a better way than what I gave above. —Tamfang (talk) 03:36, 27 October 2008 (UTC)[reply]

So there is no a program that do this, and I will have to program for myself if I want one??? 201.79.105.113 (talk) 17:17, 25 October 2008 (UTC)[reply]

Sure there are loads. I just had a go on my GNU Octave and it does it. You could download that. You can just type in what you want:
octave:9> gcd(300,45,90)
ans =  15
octave:10> lcm(45,5,2,54)
ans =  270
octave:11>  —Preceding unsigned comment added by 3sJJ0Itf (talkcontribs) 17:36, 25 October 2008 (UTC)[reply] 
and it can do lots of other stuff too. —Preceding unsigned comment added by 3sJJ0Itf (talkcontribs) 17:39, 25 October 2008 (UTC)[reply]

Based on those Python examples, I just hacked up a JavaScript solution. Type any number of integers, separated by commas, into the first box, and click "calculate". View the source for how it's done, and let me know if it's all wrong. - IMSoP (talk) 17:48, 25 October 2008 (UTC)[reply]

imsop without even looking in your code i found a problem in your program (site), I calculate the lcm of 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 and the site gave me 90. 90 is not cm of 4. 201.79.105.113 (talk) 02:05, 27 October 2008 (UTC)[reply]
The flaw in IMSoP's code is that apply_to_list keeps no history. It should be:
z = list[i];
for (i=1; i<list.length; i++) { z = func(z,list[i]); }
return z;
Tamfang (talk) 05:21, 27 October 2008 (UTC)[reply]
D'oh! Just for the sake of it, I've fixed the page. - IMSoP (talk) 13:07, 27 October 2008 (UTC)[reply]

If you want something less programmatic, with a GUI, there's GraphCalc. It has gcb and lcm functions. Although, as with the Python examples, it only takes two arguments at a time. - RedWordSmith (talk) 02:30, 26 October 2008 (UTC)[reply]

It would help if we knew what the OP needs in a bit more detail: a function library? a standalone app? to be run from a command line or otherwise? —Tamfang (talk) 05:21, 27 October 2008 (UTC)[reply]

This was the first programming homework I got! Graeme Bartlett (talk) 05:33, 27 October 2008 (UTC)[reply]

A standalone program. But dont need to be graphical, just something that at the start of the program that: Say "What is the amount of numbers that you will use to calculate" then the user put the amount of numbers that will be used in calculation?" Then the user put the amount of numbers used for calculation. A example 3. Then its say "insert the first number" and the user do that, then "insert the second number" and the user insert, and then "insert the 3rd number" and the user do that and then the program show the lcm and the gcd of those numbers that user inserted. Just a program as simple as that is ok. 200.242.17.1 (talk) 22:19, 27 October 2008 (UTC)[reply]

USB cord and iPod problems[edit]

The USB cord I use for my iPod has a burnt smell after I use it and it will no longer fit into one of the connectors of my computer, which hasn't happened before. Also my iPod has a weird black patch/line that is slowly spreading on the screen, and it's certainly not a crack. I tried restoring it to see if it would go away, but nothing. It even appears when the iPod is turned off. --Crackthewhip775 (talk) 04:55, 25 October 2008 (UTC)[reply]

This happened to my iPod as well. The black line (in my case) were scars from electrical burns. It turned out not to be an iPod problem, but the USB port. It will fry anything I plug into it. Louis Waweru  Talk  10:56, 25 October 2008 (UTC)[reply]

Text Messages AUTOMATICALLY FORWARDED to email[edit]

Hello,

Just wondering if there is a way for T-Mobile text messages from my cell phone to automatically be forwarded to a personal email address. Is there a certain phone setting I can try to use to accomplish this...or perhaps freeware that allows me to set this up? Thanks in advance!

See SMS_Gateway#Carrier-provided_SMS_to_Email_Gateways.WikiY Talk 17:11, 25 October 2008 (UTC)[reply]

files between each compuetsr[edit]

Is there anything that would enable two people on different computers to connect to a server and transfer a file between the two computers. The server would not receive the file it would just be acting as a sort of first step to link the two computers together to begin with, like give each of them the other's ip address and then the servers job is done and the download takes place between the computers themselves. —Preceding unsigned comment added by Owattt (talkcontribs) 13:46, 25 October 2008 (UTC)[reply]

If the computers were close together, I'd just use a router, flash drive, or cross-over cable to do that job. Useight (talk) 14:42, 25 October 2008 (UTC)[reply]
FTP. -59.95.115.215 (talk) 15:57, 25 October 2008 (UTC)[reply]
FTP does not connect two IPs. It would have to receive the file first. Not at all what they asked for. --98.217.8.46 (talk) 22:50, 25 October 2008 (UTC)[reply]
You are basically describing how most P2P protocols work. The servers for BitTorrent or Limewire or whatever don't download the file, they just connect peers. (Basically. It's more complicated than that.) --98.217.8.46 (talk) 22:50, 25 October 2008 (UTC)[reply]
Instant messengers (AIM, Yahoo Messenger, MSN Messenger, ICQ, etc.) often have file transfer capabilities that work that way. --70.254.87.166 (talk) 00:29, 26 October 2008 (UTC)[reply]
Encryption issues aside, I think Skype works in a similar fashion. Kushal (talk) 11:33, 26 October 2008 (UTC)[reply]

OpenOffice.org 3 repository?[edit]

Resolved

I would like to know if there is any official or semi-official repository or PPA for OpenOffice.org 3? I know I can use the debs and stuff like that, but I want to do this in a "clean" way... SF007 (talk) 16:02, 25 October 2008 (UTC)[reply]

I Think I found it! [1] SF007 (talk) 16:58, 27 October 2008 (UTC)[reply]

Scalability of Linux[edit]

Assuming I invent a quad-core 2048-bit RISC processor, how difficult (or easy) is it to scale Linux so that it takes maximum advantage of the architecture? For example, I would like a standard Ubuntu distribution (and all its applications) to work on this architecture. =Nichalp «Talk»= 16:35, 25 October 2008 (UTC)[reply]

Most of the work is recoding the back-end for gcc to take advantage of your architecture (more on that in a second). With that done porting linux is fairly straightforward; unless you make odd choices for your processor design. Multi-processor and multi-core is a solved problem (linux runs on sparc, cell, recent intel, and a bunch more). RISC or not is essentially purely a problem for gcc (and the code generators of other languages like python, java, haskell etc.) But that 2048-bit thing is harder, mostly because a 2048 bit machine is essentially pointless. The number of applications which need 2048-bit integers, or fp precision of that massive degree, is vanishingly small. So, with a conventional RISC instruction set your massive registers will still mostly be hauling around "0" and "255" and "c" most of the time. And having to waste 2k of cache to store a single character will make you proposed processor comically slow. Now maybe you're thinking of having a bunch of instructions "horizontally" in that 2048 bit instruction word (and keeping data-words at a manageable size like 64bit). Such very long instruction word sound nice, but they haven't panned out in practice. The trouble is keeping the (in your cases hundreds) of parallel instruction pipelines full. The first generation of VLIW machines, like Trimedia and Butterfly, tried to do this statically in the compiler - this made the compiler incredibly difficult to write, and mostly the compilers failed to keep even the five pipelines Trimedia had full (Butterfly's pipelines were more numerous and more varied, but the compiler was no more successful). Second generation VLIW architectures, like Crusoe and MAJC, tried to do this instruction scheduling dynamically, with a dynamic compiler at runtime rather than a static one. They were a bit more successful than the 1st gen, but not enough to justify the increased cost complexity. So, in short, the linux port is straightforward (if your processor isn't mad), the gcc port is okay, but your 2048 bit architecture is useless. 87.115.33.241 (talk) 17:47, 25 October 2008 (UTC)[reply]
If you really did have some special single purpose for which the 2048-bits were necessary (some simulation or crypto purpose) then you'd be better to build a dedicated DSP and hang that off a regular CPU as a slave. Almost all such applications are mindless datapumps, for which even the most rudimentary OS is unnecessary. You would't want to run Linux on it, for the reasons above. And if you really do have such a single-purpose application, an FPGA or ASIC is probably a much more efficient way to do things than building a special DSP for it. 87.115.33.241 (talk) 17:52, 25 October 2008 (UTC)[reply]
Thanks. Yes, I was thinking of 2048-bit instructions. So scalability in processors is an unlikely thing I suppose. I wonder what the next big think in processor design is. =Nichalp «Talk»= 10:03, 26 October 2008 (UTC)[reply]
Dozens or hundreds of cores in a NUMA configuration (like Cell, but more so), although programming for that, and keeping all those cores doing something useful, is also very difficult. Reconfigurable computing. Better back-ends for side-effect free pure-functional languages like Haskell, as this seems to be the only practical way in which a normal programmer can expect to write code that effectively runs on hundreds of threads. 87.115.33.241 (talk) 13:41, 26 October 2008 (UTC)[reply]
I wonder if I can use Wikipedia logs to invalidate patents in processor design by claiming prior art. Kushal (talk) 11:31, 26 October 2008 (UTC)[reply]

teachnology and communication world[edit]

1.what is the main difference between bit and brt? 2.what is the significances of ICANN? 3.DEFINE the following words; a).IP adress b).HYPERLINK c).WIMAX 195.24.211.162 (talk) 18:01, 25 October 2008 (UTC)[reply]

The reference desk won;t do homework for you. You can probably find the answers on the relevant Wikipedia articles anyway, though I haven't looked. Ale_Jrbtalk 18:04, 25 October 2008 (UTC)[reply]
Bit, byte, ICANN, TCP/IP address, hyperlink and WIMAX? Never heard of any of those. Now, would an online encyclopedia not be handy for little problems like that ... --Cookatoo.ergo.ZooM (talk) 21:01, 25 October 2008 (UTC)[reply]

I would be interested in knowing what you mean by a brt, though. Kushal (talk) 19:24, 26 October 2008 (UTC)[reply]

Possibly bitrate. --NorwegianBlue talk 20:48, 26 October 2008 (UTC)[reply]

Java IO[edit]

I'm writing a game program, designed to read from and write to the command line. I'd like it to respond to individual keypresses - you press a 5, it does something. So far, all the input systems I can find (InputStreamReader(System.in), etc) refuse to do anything until you've pressed enter. Anybody know a way around that? Black Carrot (talk) 22:54, 25 October 2008 (UTC)[reply]

No, I don't think there's anything you can do. I think the shell(?) itself buffers your input until you press enter, and then sends it to the program. So to change this you probably have to go through C and assess some OS-dependent library that deals with text environments. --71.106.183.17 (talk) 09:34, 26 October 2008 (UTC)[reply]
Yeah, there are various curses interfaces for java and things, but you will lose portability, and it will in general be more of a pain to program. If you've gotten that far, I'd suggest programming a simple gui for your game, then you can listen to all the keystrokes you want. 13:10, 26 October 2008 (UTC) Belisarius (talk) 13:11, 26 October 2008 (UTC)[reply]

Thanks. I'd hoped to avoid it, but I guess a simple GUI is the easiest way. Black Carrot (talk) 17:52, 26 October 2008 (UTC)[reply]

If you're on Linux/OS X and don't mind losing portability, then doing:
stty raw; java MyProgram; stty -raw
will do what you want. --Sean 19:01, 26 October 2008 (UTC)[reply]

Downloading a Perl Script[edit]

Does anyone know how to download a Perl script used for a form? I tried linking it in a page and right-clicking, then selecting Save Target As ... but all I get is an HTML page saying that the GET method isn't allowed for the script. It's hosted by my university for activating forms on student web pages. But I don't know what parameters to pass to it since I can't see the source code.--Account created to post on Reference Desk (talk) 23:10, 25 October 2008 (UTC)[reply]

You won't generally be able to download the source for a server-side script like that unless the person running that web server has specifically given you a way of doing so. If you've got some other access to the server other than the standard web interface - e.g. a file share or shell access - maybe you could get it that way? - IMSoP (talk) 23:23, 25 October 2008 (UTC)[reply]
Sometimes you can try to see if there is a file with a tilde ( ~ ) after the filename. Many text editors, like Emacs and gedit, by default save a backup file that is the same as the filename except with a tilde at the end. Other editors might use other suffixes. Assuming the person used one of these editors, that the editor was configured to save a backup file, the file is located in a directory that the web server will display the contents from (i.e. many web servers won't just display a text file from a cgi-bin directory, considering it to be a script, especially if it is executable), the file is permissioned in a way that is readable to the web server, and the person is careless to not delete backup files when he's done editing, then you might be able to get the contents of the previous version of the script this way. --71.106.183.17 (talk) 00:21, 26 October 2008 (UTC)[reply]
Thanks for the replies. My pages are hosted on a different server from the script. So, I can't seem to find it when I telnet in. I couldn't find any temp files, either. Thank you anyway.--Account created to post on Reference Desk (talk) 01:34, 26 October 2008 (UTC)[reply]

Clicking "Safely Remove Hardware" disconnects from Internet[edit]

OK, knowledgeable people, answer me this: I'm running Windows XP, with a SpeedTouch ADSL USB modem thingy, and it works fine, mostly. But if I click on the "Safely Remove Hardware" icon in the system tray - say, to remove my USB keyring drive or scanner - the modem immediately disconnects from the Internet. Note that I don't mean I'm clicking on anything in that menu, just getting that menu up by clicking on the icon is enough.

Now, the questions are: 1) Why is this happening? How on earth does my modem even know I'm displaying that menu, let alone see it as a signal to break the connection? and 2) Is there anything I can do about it, because it's extremely annoying if I've got connections open that I don't want to reset (downloads, chat, etc) - IMSoP (talk) 23:18, 25 October 2008 (UTC)[reply]

Are you getting disconnected from the internet or from the SpeedTouch modem? So in other words, can you still access your SpeedTouch modem? My first assumption would be you are getting disconnected from the modem, which could be happening since it's connected via a USB cable. But if the problem is that you can access your modem but on the internet, then I have no idea how that can happen. - Akamad (talk) 09:24, 26 October 2008 (UTC)[reply]
Well, the symptoms are simply that as soon as I click the icon, the Internet connection goes down and immediately tries to "redial". Normally, it picks straight back up again, but obviously all my applications have to re-establish their connections. Although, while testing it today, I've had it completely fail to come back a couple of times, and actually had to reboot my computer to reset the modem, which is odd.
Notably, the lights on the modem do not change during this process, suggesting that the USB connection retains power (otherwise it would need to reload its "firmware"). I've also upgraded the driver to the latest version from the Thomson website, but that hasn't helped.
I can only assume that to display that menu, Windows polls all the connected devices, and that polling is somehow "confusing" the modem and causing it to unsync. But I don't even know if that's the modem's fault or Windows's - most devices don't really need to stay in sync like that, so I imagine I wouldn't notice. - IMSoP (talk) 16:54, 26 October 2008 (UTC)[reply]
  • Ask your ISP an ethernet modem, (my old ISP used to replace the USB ones for free, just say you modem does not work on your operating system) it solves 99% of the problems you might have with the internet connection:
  • No crappy drivers to install (none at all!)
  • Works on all OSes
  • No bluescreens and crap like that due to the drivers (I used to have them)
  • No more problems like the ones you mentioned.

Seriously, get yourself and ethernet modem ASAP! SF007 (talk) 00:24, 27 October 2008 (UTC)[reply]