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 7693713
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T21:09:09+00:00 2026-05-31T21:09:09+00:00

I have a method to calculate the exponent, but it doesnt like the c

  • 0

I have a method to calculate the exponent, but it doesnt like the c := c * a. If i do something like c := a. it works and im unsure why its behaving this way when i try and do c := c *a.. Im new to Smalltalk, so maybe its just something im missing. Im using Pharo as my implementaton.

testPow: i1 exp: i2
    "Testing exponent. i1 and i2 are integers, we calculate and then return the value as a Church numeral"
    | a b c |

    a := i1.
    b := i2.

        1 to: b do: [ :i |
      c:= c*a.
    ].
^c.
  • 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-31T21:09:11+00:00Added an answer on May 31, 2026 at 9:09 pm

    You need to initialise c before using it. With your statement:

    c := a
    

    it works because a has a value. With:

    c := c * a
    

    it won’t work because the first time through the loop, c will not be initialised to anything useful.

    Just change your initialisation section to:

    a := i1.
    b := i2.
    c := 1.
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Seems like in Perl this should be easy or a module, but I have
I have written a method to calculate a given percentile for a set of
I have this method on a webpart: private IFilterData _filterData = null; [ConnectionConsumer(Filter Data
I found in xna this method to calculate the length of an audio sample
I have a method which just increases an Integer Value (i++) public void Calculate()
Does .NET have a built-in method to calculate the ULP of a given double
I have a method which uses following logic to calculate difference between days. long
I have this method that converts a signed or non-signed byte to int ,
I have this method for figuring out the difference between 2 0-360 compass headings.
I have this code but it doesn't work! public class Trial { public static

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.