Project Euler – Problem # 1 – Solved with Java & Python

If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23.

Find the sum of all the multiples of 3 or 5 below 1000.

**********

I have been learning Java from internet tutorials. If you see some code that can be improved on, feel free to leave a comment.

One Possible Solution: Java

public class Problem1 {
	public static void main(String[] args){
		int sum = 0;
		for(int counter = 1; counter < 1000; counter++){
			if(counter % 3 == 0 || counter % 5 == 0){
				sum = sum + counter;
			}else{
				continue;
			}
		}
		System.out.println(sum);
	}

}

One Possible Solution: Python

# Python version = 2.7.2
# Platform = win32

sum = 0
for i in range(1, 1000):
    if i % 3 == 0 or i % 5 == 0:
        sum = sum + i
print "Answer = ", sum
Advertisements

Deer Mountain in Rocky Mountain National Park

Today I set out to climb Deer Mountain in Rocky Mountain National Park. It would be the first time since I started climbing this mountain that I didn’t make it to the summit. I’ve climbed it at least 15 times since the late 1990’s and early 2000’s.

It started out OK, just dirt and ice for a trail. I decided not to wear my trackers, and just tread extra carefully on the icy spots. The farther up the mountain I went, the more snow was on the trail. I got all the way to the top (false summit) where it levels out and lost the trail. Several other people have also climbed it recently, and the most traveled path took the south ridge of Deer Mountain and I decided to follow it. It looked like the people who set out on this path new how to get to the top another way than the normal trail; however, after following it for about 10 minutes it all the sudden stopped and whoever made the trail just retreated back down the mountain. Someone else also started to trek where the trail should have been, but they also stopped after only about 50 yards. I could have gone on if I had my snowshoes on – although I am not sure I could have found the trail. So no-one has been to the top of Deer Mountain in recent days. It may be spring time when someone actually summits again, unless they can be a trailblazer and snowshoe through some deep snow, find the trail, then reach the summit. Who knows it may happen.

After getting stopped in my tracks, I just hiked back down the mountain. I had to take very small steps on the icy parts and still took a tumble or two, once falling about 5 yards down a hill and off the trail. It was good to get out in the Park on such a sunny day.

PHOTOS: http://www.flickr.com/photos/99887494@N02/sets/72157635081883555/

If you watch the slideshow, I contrasted the photos with some I took last July 4th when I climbed clear to the top. I tried to take a picture from approximately the same location as the last time I climbed – to show you a summer photo and a winter photo.

Mills Lake

Today I took the Mills Lake snowshoe challenge. I challenged myself to not stopping very much for rest. The round trip is about 6 miles, and I accomplished my goal. I actually did not wear snowshoes, but wore my trackers. They worked great. The trail was mostly packed powder, with a few icy spots. The trackers are almost as good as snowshoes, I didn’t have to worry about falling down at any time during the hike.

PHOTOS: http://www.flickr.com/photos/99887494@N02/sets/72157635088368776/

The wind was blowing some, the tree cover kept it from blowing snow over the trail. Once at Mills Lake, there was a real big gust of wind for about 10 seconds – I had to turn my back to it so as not to get stung by the snow pellets. After the gust, it was fairly still for a while. Awesome beauty is all I can say!