Skip to main content
gamedev.net
🔒 Locked

[java] Problem with divisor program++fixed++

Started by kyokai Sep 5, 2006 at 12:55 PM 1 replies 1.1k views
Original Post
kyokai
kyokai
Alright...I'm working on a program for a summer assignment, and I need some help with it... I have to write a program that takes a positive integer as an input and displays a message box that includes wether or not the number is perfect, deficient, or abundent. I was given two methods to use... boolean isDivisor (int number, int divisor) and... int divisorSum (int number) A perfect number being a number that the sum of the divisors equals the number. 28 = 1+2+4+7+14 as an example of a perfect number. If the sum of the divisors is less than the number, it is deficient, if it is greater than the number, it is abundant. The part i'm having trouble with is using the methods, and also the math part of the problem. Many thanks in advance, Kyokai ++i got it figured out++ [Edited by - kyokai on September 6, 2006 9:24:56 PM]
ToohrVyk
ToohrVyk
Do you have to write these functions, or are they already available?
Ezbez
Ezbez
Note that we can't help with homework. Not sure if this is for a class or not, so here's some vague suggestion:

I'd start off by finding all divisors of the given number.

Edit: And just for clarification, are you counting 1 as a divisor? Are you counting a number as it's own divisor? Looks like yes then no for those questions, respectively, but just double checking.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.