Hi guys!
Starting today I'm going to start making the applications listed here:
His magnificent thread.
I'm mainly a C# programmer, but I'm really scared recently. Why? Because I feel I'm getting extremely rusty. I can read a million books, but I'll never be truly good at what I do until I actually do it.
Martyr2's thread is a great resource for new programmers and even novices who are rusty. Since I'm having trouble coming up with programs to try to make, I've decided this.
I'm going to make the program using C# and Python 2.6. I really hope people follow the examples and try to do the same thing because his thread is a real gem.
Tomorrow, I update the blog with solutions to the first three problems.
Wish me luck.
Starting today I'm going to start making the applications listed here:
His magnificent thread.
I'm mainly a C# programmer, but I'm really scared recently. Why? Because I feel I'm getting extremely rusty. I can read a million books, but I'll never be truly good at what I do until I actually do it.
Martyr2's thread is a great resource for new programmers and even novices who are rusty. Since I'm having trouble coming up with programs to try to make, I've decided this.
I'm going to make the program using C# and Python 2.6. I really hope people follow the examples and try to do the same thing because his thread is a real gem.
Tomorrow, I update the blog with solutions to the first three problems.
Quote
Find PI to the Nth Digit – Enter a number and have the program generate PI up to that many decimal places. Keep a limit to how far the program will go.
Fibonacci Sequence – Enter a number and have the program generate the Fibonacci sequence to that number or to the Nth number.
Prime Factorization – Have the user enter a number and find all Prime Factors (if there are any) and display them.
Fibonacci Sequence – Enter a number and have the program generate the Fibonacci sequence to that number or to the Nth number.
Prime Factorization – Have the user enter a number and find all Prime Factors (if there are any) and display them.
Wish me luck.
1 Comments On This Entry
Page 1 of 1
Ferencn
10 February 2010  08:23 AM
Hey!
Inspired by your quest I wrote a first python script as well!
It's the prime factor finder... After some thinking i came up with the following, recursive algorithm, in pseudocode:
Edit: woke up and realized that the check for prime is unnecessary!
consider the candidate:
if candidate >=4 (2 and 3 are primes, 1 cannot be factorized)
if candidate is even
then 2 is a factor.
else
is any odd number from 3 to the root of the candidate a divisor of candidate?
and the divisor is a prime? then that number is a factor!
factor found?
print it and then consider (candidate/factor).
else
print the candidate and done!
and this is what it looks like when i implemented it in python:
I think it can be optimized a bit by passing the last found factor as the value to
start with, when searching for the next divisor....
looking forward to seeing what you came up with!
Inspired by your quest I wrote a first python script as well!
It's the prime factor finder... After some thinking i came up with the following, recursive algorithm, in pseudocode:
Edit: woke up and realized that the check for prime is unnecessary!
consider the candidate:
if candidate >=4 (2 and 3 are primes, 1 cannot be factorized)
if candidate is even
then 2 is a factor.
else
is any odd number from 3 to the root of the candidate a divisor of candidate?
factor found?
print it and then consider (candidate/factor).
else
print the candidate and done!
and this is what it looks like when i implemented it in python:
from math import * def findfactors(intarget): factor = 1 if intarget >= 4: # 2 and 3 are primes! if (intarget % 2)==0: factor = 2 else: checkto = int(sqrt(intarget)) for candidate in range(3,checkto+1,2): if intarget%candidate == 0: factor = candidate break if factor != 1: print factor, ' ', findfactors(intarget/factor) else: print intarget
I think it can be optimized a bit by passing the last found factor as the value to
start with, when searching for the next divisor....
looking forward to seeing what you came up with!
Page 1 of 1
Trackbacks for this entry [ Trackback URL ]
← August 2014 →
S  M  T  W  T  F  S 

1  2  
3  4  5  6  7  8  9 
10  11  12  13  14  15  16 
17  18  19  20  21  22  23 
24  25  26  27  28  29  30 
31 
My Blog Links
Recent Entries

I'm going to start chowing down the Martyr2 Mega Project list.
on Feb 08 2004 06:26 PM
Recent Comments

comptechexpert on Mar 26 2010 10:24 AM
Completed some more projects off the Mega Project List on DIC.
Search My Blog
0 user(s) viewing
0 Guests
0 member(s)
0 anonymous member(s)
0 member(s)
0 anonymous member(s)
