Submit solution
Points:
5
Time limit:
2.0s
Memory limit:
64M
Problem type
Allowed languages
Ada, Assembly, Awk, Brain****, C, C#, C++, COBOL, CommonLisp, D, Dart, F#, Forth, Fortran, Go, Groovy, Haskell, Intercal, Java, JS, Kotlin, Lisp, Lua, Nim, ObjC, OCaml, Octave, Pascal, Perl, PHP, Pike, Prolog, Python, Racket, Ruby, Rust, Scala, Scheme, Sed, Swift, TCL, Text, Turing, VB, Zig
Write a program that repeatedly reads a positive integer, determines if the integer is deficient, perfect, or abundant, and outputs the number along with its classification.
A positive integer, , is said to be perfect if the sum of its proper divisors equals the number itself. (Proper divisors include
but not the number itself.) If this sum is less than
, the number is deficient, and if the sum is greater than
, the number is abundant.
The input starts with the number of integers that follow. For each of the following integers, your program should output the classification, as given below. You may assume that the input integers are greater than and less than
.
Sample Input
3
4
6
12
Sample output
4 is a deficient number.
6 is a perfect number.
12 is an abundant number.
CCC problem statements in large part from the PEG OJ
Comments
It took me a long time to realize I was outputting "a abundant" instead of "an abundant"
I have a strange comment, kind of related to the question, how many perfect integers are there up until say up until 2,147,483,647? I wrote a program, but in about 15 minutes it only got 4. And those where 6, 28, 496, and 8128. Has anybody else been able to actually get a complete list?
A quick search found a good answer to your question. In case you're too lazy to read the link, I can summarize:
The current limitations are:
https://en.wikipedia.org/wiki/Perfect_number
Forgot that you have to use an instead of a before another word that starts with a vowel. FP -> Facepalm
(-‸ლ)
Forgot the period, whoops
My code acts differently when running in the judge?
This comment is hidden due to too much negative feedback. Click here to view it.
In your for-loop, is there a reason you are looping up until
num/2+2
? It doesn't seem intuitive why you need to add 2.This comment is hidden due to too much negative feedback. Click here to view it.
What do you not understand? Perhaps your comment could be better phrased simply stating your problem.
This comment is hidden due to too much negative feedback. Click here to view it.
Because it is not clear, I am going to assume you are asking a question.