View Single Post
  #1 (permalink)  
Old 09-23-2007, 07:39 PM
Umbongo
Posts: n/a
[SOLVED] Math functions in Python

I recently came across Project Euler; for those unfamiliar it is a challenge combining math and programming skills. Unfortunately, I have no programming abilities and as such am unable to solve even the third problem without cheating.

I know how I would like to approach the problem, but not how I can write it in python. The question involves finding the prime factors of a large number (317584931803).

I want to use the functions:
f(x)=number/x
and
g(x)=x-int(x)
to form the composition g(f(x))=f(x)-int(f(x))

and then have it test the values of x when g(f(x))=0 for primeness, and print those values which are prime.

So, in short, how are functions written in python?
Err...and if anyone has time, how would the above be written?

__________________

Digg this Post! Del.Icio.Us this Post! Technorati this Post! Furl this Post! Mister Wong this Post! Newsvine this Post! Spurl this Post! Reddit this Post! Netscape this Post!