2015-07-29 5:29 GMT+02:00 Job Hernandez <jobrh2...@gmail.com>: > How is it going tutors? > > The following problem seems impossible to me: > > "*Write a program that asks the user to enter an integer and prints two > integers, root and pwr, such that 0 < pwr < 6 and root^pwr (root**pwr) is > equal to the integer entered by the user. If no such pair of integers > exists, it should print a message to that effect*." > > I would like to solve this problem myself so please don't give me the > solution. > > I need to learn how in the world do find the root and power of an integer > that x user entered? I haven been looking on the python website for an > appropriate function but I have not. > > If you have the time can you please tell me about the functions and other > facts I need to know in order to solve this problem? > > Is there a book you guys recommend for total beginners who have no ideal of > what computer science and programming is? > > Thank you, > > Job > _______________________________________________ > Tutor maillist - Tutor@python.org > To unsubscribe or change subscription options: > https://mail.python.org/mailman/listinfo/tutor
Hello, First, you need an algorithm that solves your problem. Once you have it, you need to implement it in Python. For the algorithm. Although there are theorems and all sort of smart mathematical tricks you could use, given the conditions you have, have you considered to use a brute force approach? I mean: if all involved numbers are positive you could start testing different values for root from 0 on, and for each value test pwr from 1 to 5 until you find either a solution, something bigger than x. Once you chose the algorithm, for the actual implementation you have to say what part you are blocked at. Best. _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor