Closed Thread
Results 1 to 4 of 4

Thread: python maths post-shortened now. promise! please look

  1. #1
    amateur is offline Newbie
    Join Date
    Jul 2009
    Posts
    8
    Rep Power
    0

    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 05:03 PM.

  2. CODECALL Circuit advertisement
    Join Date
    Always
    Posts
    Many

     
  3. #2
    amateur is offline Newbie
    Join Date
    Jul 2009
    Posts
    8
    Rep Power
    0

    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.

  4. #3
    Join Date
    Sep 2008
    Location
    Australia
    Posts
    4,834
    Blog Entries
    10
    Rep Power
    51

    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!

  5. #4
    Hignar's Avatar
    Hignar is offline Programming Expert
    Join Date
    May 2009
    Posts
    419
    Blog Entries
    2
    Rep Power
    12

    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.

Closed Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 3
    Last Post: 02-05-2011, 11:12 PM
  2. Some JS maths help please!
    By jaydee in forum JavaScript and CSS
    Replies: 7
    Last Post: 07-27-2010, 09:13 AM
  3. Maths dll and asp.net Help
    By avosoft in forum ASP, ASP.NET and Coldfusion
    Replies: 3
    Last Post: 06-05-2010, 11:56 PM
  4. Ask Me Any Maths Questions
    By PythonPower in forum Games
    Replies: 85
    Last Post: 05-23-2010, 12:10 PM
  5. Maths Help (Surds)
    By Brandon W in forum The Lounge
    Replies: 12
    Last Post: 02-08-2009, 04:14 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts