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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T17:38:42+00:00 2026-06-15T17:38:42+00:00

I need help thinking up a formula for finding the factors of a number:

  • 0

I need help thinking up a formula for finding the factors of a number:

Write a method named printFactors that accepts an integer as its
parameter and uses a fencepost loop to print the factors of that
number, separated by the word ” and “. For example, the number 24’s
factors should print as:

1 and 2 and 3 and 4 and 6 and 8 and 12 and 24

You may assume that the number parameter’s value is greater than 0.

Please don’t give me a COMPLETE program as I would like to try it out myself.

The current code I have has a for loop to control the number of “and’s” appearing, however, I printed out the last number by itself since I don’t want a “24 and” attached to it…
So the output looks something like this at the moment:
“1 and 2 and 3” (I haven’t yet thought up the equation hence the 1,2,3…)

I’m currently thinking that the factors requires a % kind of formula right? Will I need division? I was also thinking of printing out 1 and whatever the number (in this case, 24) you are finding factors for, since 1 and the number itself are always factors of itself.
What else am I missing??

Thanks in advance!! 🙂

  • 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-15T17:38:43+00:00Added an answer on June 15, 2026 at 5:38 pm

    I’m currently thinking that the factors requires a % kind of formula right?

    Yes.

    I was also thinking of printing out 1 and whatever the number (in this case, 24) you are finding factors for, since 1 and the number itself are always factors of itself.

    If you test every number from 1 to n (e.g. from 1 to 24) then 1 and the number itself don’t need to be special cases (because they’ll simply satisfy your ordinary “% kind of formula”).

    Maybe 1 is a special case because it doesn’t have the word “and” in front of it.

    What else am I missing??

    This may be more complicated than you want, but to find all the factors of n you only need to loop up to the square root of n.

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

Sidebar

Related Questions

I need help converting a string that contains a number in scientific notation to
Need help with a query that I wrote: I have three tables Company id
I need help thinking up a design where clients connect and communicate with all
I need some help in thinking through the process to do batch update on
I need some help on figuring out a way to store my data that
I actually need help on the thinking process and options, and not really on
I need help in this and am very confusing thinking how to do this.
Hi I need help to understand the decode part of a query that goes
Once again I need your Help, am thanking you as every time you helped
Need help, function getFamily() { FB.api('/me/family', function(response) { alert(JSON.stringify(response)); }); } With the above

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.