You are not logged in.

#1 2008-09-20 23:12:34

Stythys
Member
From: SF Bay Area
Registered: 2008-05-18
Posts: 878
Website

Project Euler #14

hey guys! new to programming in general...working on some of the project euler problems. I'm on #14 and I'm getting this weird loop that I can't explain. any help would be appreciated...it's probably just me being a nubhead =P

Screenshot

Basically when it reaches odd numbers it seems to be multiplying them wrong...they're two behind so like when on 61 it'll end up to 182 instead of 184....

Weird part is the program seems to work fine until somewhere between numbers 110,000 and 115,000

Last edited by Stythys (2008-09-20 23:13:17)


[home page] -- [code / configs]

"Once you go Arch, you must remain there for life or else Allan will track you down and break you."
-- Bregol

Offline

#2 2008-09-20 23:19:11

moljac024
Member
From: Serbia
Registered: 2008-01-29
Posts: 2,676

Re: Project Euler #14

You dare post a screenshot of that operating system here ? Naughty naughty!

Last edited by moljac024 (2008-09-20 23:20:21)


The day Microsoft makes a product that doesn't suck, is the day they make a vacuum cleaner.
--------------------------------------------------------------------------------------------------------------
But if they tell you that I've lost my mind, maybe it's not gone just a little hard to find...

Offline

#3 2008-09-20 23:27:18

Stythys
Member
From: SF Bay Area
Registered: 2008-05-18
Posts: 878
Website

Re: Project Euler #14

haha, yeah sorry xD

I'm using windows for about a month until I get my new computer 'cause my graphics card isn't fully supported under linux, and there are no upgrade slots unless I get a new mobo and everything. Just one more month of hell.....lol


[home page] -- [code / configs]

"Once you go Arch, you must remain there for life or else Allan will track you down and break you."
-- Bregol

Offline

#4 2008-09-20 23:34:12

Allan
Pacman
From: Brisbane, AU
Registered: 2007-06-09
Posts: 11,365
Website

Re: Project Euler #14

For some reason your numbers are all negative so it is really going from -61 to -182 as expected. 

You are using a short int for your number (from memory int == short int) and so a suffering roll over.  You will want to use an unsigned long for numbers that can be bigger than a million and only positive.

Offline

#5 2008-09-20 23:35:58

Stythys
Member
From: SF Bay Area
Registered: 2008-05-18
Posts: 878
Website

Re: Project Euler #14

ahhhhh gotcha. Thanks big_smile


[home page] -- [code / configs]

"Once you go Arch, you must remain there for life or else Allan will track you down and break you."
-- Bregol

Offline

Board footer

Powered by FluxBB