Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7066621
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T05:06:12+00:00 2026-05-28T05:06:12+00:00

OK, our professor explained (kinda) this problem, but it still doesn’t make much sense.

  • 0

OK, our professor explained (kinda) this problem, but it still doesn’t make much sense.

Question: Implement the function knice(f,a,b,k) that will return 1 if for some integer a <= x <= b and some integer n <= k, n applications of f on x will be x, (e.g. f(f(f...(f(x)))) = x) and 0 if not.

What the professor provided was:

def knice(f,a,b,k):
    f(f(f(...(f(x)))) = x
    for i = a to b:
        y = f(i)
        if y = i break
    for j = z to k:
        y = f(y)
        if y = i break

Personally, that example makes no sense to me, so looking to see if I can get clarification.

OP EDIT 1/19/2012 3:03pm CST

This is the final function that was figured out with the help of the GTA:

def f(x):
    return 2*x-3

def knice(f,a,b,k):
x = a
while x <= b:
    n = 1
    y = f(x)
    if y == x:
        return 1
    while n <= k:
        y = f(y)
        n=n+1
        if y == x:
            return 1
    x=x+1   
return 0
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T05:06:12+00:00Added an answer on May 28, 2026 at 5:06 am

    Ignore his code; you should write whatever you feel comfortable with and work out the kinks later.

    You want to work out whether

    • f(a) = a, or f(f(a)) = a, or …, or f^n(a) = a, or,
    • f(a+1) = a+1, or f(f(a+1)) = a+1, or …, or f^n(a+1) = a+1, or,
    • …
    • f(b) = b, or f(f(b)) = b, or …, or f^n(b) = b.

    An obvious algorithm should come to mind immediately: try all these values one-by-one! You will need two (nested) loops, because you are iterating over a rectangle of values. Can you now see what to do?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've taken 2 OOP C# classes, but now our professor is switching over to
Im trying to make a simple 2D application, and our image processing professor has
First off, let me preface this question by saying that my professor is firmly
Sorry if this is not the type of question to be asked here but
I was given some code by our professor with some things I have never
This is probably a very easy question. Hey I'm a student and relatively new
My professor told us that we could choose a programming language for our next
In my work with my professor I have to ssh into our server and
Our professor required us to check if a word is a palindrome by using
I'm taking a compiler-design class where we have to implement our own compiler (using

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.