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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T08:00:33+00:00 2026-06-03T08:00:33+00:00

Assume that the method enigma has been defined as follows: public int enigma(int n)

  • 0

Assume that the method enigma has been defined as follows:

public int enigma(int n)
{
    int m;

    while (n >= 10) {
        m = 0;
        while (n > 10) {
            m += n % 10;
            n /= 10;
        }
        n = m;
    }
    return (n);
}

What is the value of enigma(1995) ?
I understood that the value of enigma(1995) is 3. What is the step by step?

  • 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-06-03T08:00:35+00:00Added an answer on June 3, 2026 at 8:00 am

    The outer while runs until n becomes less than 10.

    The inner loop runs until n becomes less than or equal to 10, then we assign the value of m to n, so the outer loop can be evaluated again.

    What happens in the inner loop? m is incremented by the remainder of n divided by 10 (so 5 when n==1995), then n is set to be the (integer) result of the division (so now n==199). This is repeated a few times:

    n=1995 => m=5,n=f199
    n=199  => m=5+9=14,n=19
    n=19   => m=14+9=23,n=1
    

    Since n is now not larger than 10, the inner loop ends and n is set to m(==23), then we do this again:

    n=23 => m=3,n=2
    

    Since n is now not larger than 10, the inner loop ends and n is set to m(==3). Since now n is less than 10, the outer loop exist and we arrived to the result of n(==3).

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

Sidebar

Related Questions

Assume that the class Data is defined as {DateTime TransactionDate, int ItemCount} . I
Assume that I have a particular class of object that defines a class method
Assume that I have a backbone model that has a bunch of boolean attributes:
I am currently implementing a method that accepts two bitmap objects. We can assume
Assume that we have two classes public class EntityA { public EntityB EntityB {
Example: I have an variable like $method = doSomething; Assume that I have an
How can I write a unit test for a method that has a using
Assume we have a trivial Java program that consists of just one class: public
Assume that a website has set the directory listing permissions open for one of
My ProductRepository has a method, lets say: GetAllCalculatedProducs(int categoryId) {} This method uses class

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.