Go Back   CodeCall Programming Forum > Software Development > Python
Register Blogs Search Today's Posts Mark Forums Read

Python Discussion forum for Python, a high-level language with simple syntax, but yet powerful.

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 07-07-2009, 12:34 PM
Newbie
 
Join Date: Jul 2009
Posts: 8
amateur is an unknown quantity at this point
python maths post-shortened now. promise! please look

could anyone give me the exact text i'd have to type into the python command line to make python check for integer solutions to:

Code:
n = log[base2]((7^(x)-1)/(2^(x)-1))= log[base2](7^(x)-1) - log[base2](2^(x)-1)

what i want is the code i'd have to type into python to order it to look for integer solutions up to, say, n=10000, x=10000.

Last edited by Jaan; 07-07-2009 at 08:03 PM..
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 07-07-2009, 02:58 PM
Newbie
 
Join Date: Jul 2009
Posts: 8
amateur is an unknown quantity at this point
Re: python maths post-shortened now. promise! please look

could anyone at least refer me to a guide which, if read thoroughly, would give me the answer i need?

none i have come across seem to offer answers about brute forcing...but someone on another forum claimed it was possible using python. they actually did it to an equation very similar to the one in my OP. but they ran off from the forum before i could ask them what could they typed into the command line...so i need some help from here.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 07-15-2009, 08:08 PM
Brandon W's Avatar
Code Warrior
 
Join Date: Sep 2008
Location: Australia
Age: 16
Posts: 4,824
Brandon W is a name known to allBrandon W is a name known to allBrandon W is a name known to allBrandon W is a name known to allBrandon W is a name known to allBrandon W is a name known to all
Send a message via MSN to Brandon W
Re: python maths post-shortened now. promise! please look

I don't know Python so I don't know how the code would go but wouldn't you just type a few lines of code that will allow the end user to input a number which will be stored in the variable x. Then run that line of code with the value of x and then the answer would be stored in n.

Just print the value of n then?
__________________
jQuery Selectors Tutorial - jQuery Striped Table tutorial - jQuery Events - jQuery Validation
Sorry if I don't post as often as I did, I'll try to get here as much as possible! I'm working my bum off to get this scholarship and other stuff!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 07-22-2009, 02:09 PM
Hignar's Avatar
Programming Expert
 
Join Date: May 2009
Posts: 398
Hignar will become famous soon enough
Re: python maths post-shortened now. promise! please look

To be honest I'm not sure what you are looking for. Do you want the program to try various values of x and see if n is an integer?

I've not used the maths module for python so I don't know how you'd go about entering your formula but you need a loop like this

Code:
for x in range(1,10001):
    n = log[base2]((7^(x)-1)/(2^(x)-1))= log[base2](7^(x)-1) - log[base2](2^(x)-1)
    if n-int(n) == 0:
        print x
unfortunately there is a problem with rounding error on floating point arithmetic ie if your function returns a value of 4.99999999999999999999 python will evaluate this to be 5.0 meaning the logic in the if statement above would return true. I'm not sure if there is a way round this problem.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Python Collection reachpradeep Python 1 03-03-2007 03:50 PM
How to make Dumplings ahsan16 The Lounge 2 01-11-2007 11:55 PM


All times are GMT -5. The time now is 09:26 AM.


vBulletin v3.8.0 ©2010, Jelsoft Enterprises Ltd.


no new posts

LinkBacks Enabled by vBSEO 3.1.0