Am I not good enough for you?Am I perfect (number)?Count how many numbers are divisible by perfect numbers in...
Plausibility of Mushroom Buildings
Why does Captain Marvel assume the people on this planet know this?
How strictly should I take "Candidates must be local"?
In the quantum hamiltonian, why does kinetic energy turn into an operator while potential doesn't?
Why does liquid water form when we exhale on a mirror?
Do f-stop and exposure time perfectly cancel?
PTIJ: Should I kill my computer after installing software?
How can The Temple of Elementary Evil reliably protect itself against kinetic bombardment?
PTIJ: wiping amalek’s memory?
How did Alan Turing break the enigma code using the hint given by the lady in the bar?
What does "the touch of the purple" mean?
Does "Until when" sound natural for native speakers?
Counting all the hearts
Am I not good enough for you?
If I receive an SOS signal, what is the proper response?
How to detect if C code (which needs 'extern C') is compiled in C++
Intuition behind counterexample of Euler's sum of powers conjecture
They call me Inspector Morse
What was the Kree's motivation in Captain Marvel?
Are there historical instances of the capital of a colonising country being temporarily or permanently shifted to one of its colonies?
Conservation of Mass and Energy
Does a warlock using the Darkness/Devil's Sight combo still have advantage on ranged attacks against a target outside the Darkness?
How can I get players to stop ignoring or overlooking the plot hooks I'm giving them?
Hotkey (or other quick way) to insert a keyframe for only one component of a vector-valued property?
Am I not good enough for you?
Am I perfect (number)?Count how many numbers are divisible by perfect numbers in a given rangeGenerate all 4-perfect numbersAm I perfect (number)?Is this number a factorial?Sum my Fibonaccified divisors!Do two numbers contain unique factorials?It's Hip to be SquareDo I have a prime twin?Determine SuperabundanceAm I a Pillai prime?
$begingroup$
Background:
The current Perfect Numbers challenge is rather flawed and complicated, since it asks you to output in a complex format involving the factors of the number. This is a purely decision-problem repost of the challenge.
Challenge
Given a positive integer through any standard input format, output whether it is not perfect.
A perfect number is a number that is equal to the sum of all its proper divisors (its positive divisors less than itself). For example, $6$ is a perfect number, since its divisors are $1,2,3$, which sum up to $6$, while $12$ is not a perfect number since its divisors ( $1,2,3,4,6$ ) sum up to $16$, not $12$.
Test Cases:
Imperfect:
1,12,13,18,20,1000,33550335
Perfect:
6,28,496,8128,33550336,8589869056
Rules
- Your program doesn't have to complete the larger test cases, if there's memory or time constraints, but it should be theoretically able to if it were given more memory/time.
- Output can be two distinct and consistent values through any allowed output format. If it isn't immediately obvious what represents Truthy/Falsey, please make sure to specify in your answer.
- This means your values don't have to be literally Truthy/Falsey. Your Truthy output may evaluate to false in your language and vice-versa.
code-golf number decision-problem number-theory factoring
$endgroup$
add a comment |
$begingroup$
Background:
The current Perfect Numbers challenge is rather flawed and complicated, since it asks you to output in a complex format involving the factors of the number. This is a purely decision-problem repost of the challenge.
Challenge
Given a positive integer through any standard input format, output whether it is not perfect.
A perfect number is a number that is equal to the sum of all its proper divisors (its positive divisors less than itself). For example, $6$ is a perfect number, since its divisors are $1,2,3$, which sum up to $6$, while $12$ is not a perfect number since its divisors ( $1,2,3,4,6$ ) sum up to $16$, not $12$.
Test Cases:
Imperfect:
1,12,13,18,20,1000,33550335
Perfect:
6,28,496,8128,33550336,8589869056
Rules
- Your program doesn't have to complete the larger test cases, if there's memory or time constraints, but it should be theoretically able to if it were given more memory/time.
- Output can be two distinct and consistent values through any allowed output format. If it isn't immediately obvious what represents Truthy/Falsey, please make sure to specify in your answer.
- This means your values don't have to be literally Truthy/Falsey. Your Truthy output may evaluate to false in your language and vice-versa.
code-golf number decision-problem number-theory factoring
$endgroup$
$begingroup$
Wait, so truthy is for values that aren't perfect, and falsey is for values that are?
$endgroup$
– Esolanging Fruit
50 mins ago
$begingroup$
@EsolangingFruit Yes, though the actual output values don't really matter, so you can output true for perfect numbers if you wish
$endgroup$
– Jo King
48 mins ago
$begingroup$
Fair enough, but wording the challenge as "output whether it is not perfect" makes the test cases slightly confusing if you interpret "truthy" as meaning "values corresponding to true".
$endgroup$
– Esolanging Fruit
47 mins ago
$begingroup$
@EsolangingFruit Good point. I've renamed the test cases toImperfect
/Perfect
to make it clearer
$endgroup$
– Jo King
45 mins ago
add a comment |
$begingroup$
Background:
The current Perfect Numbers challenge is rather flawed and complicated, since it asks you to output in a complex format involving the factors of the number. This is a purely decision-problem repost of the challenge.
Challenge
Given a positive integer through any standard input format, output whether it is not perfect.
A perfect number is a number that is equal to the sum of all its proper divisors (its positive divisors less than itself). For example, $6$ is a perfect number, since its divisors are $1,2,3$, which sum up to $6$, while $12$ is not a perfect number since its divisors ( $1,2,3,4,6$ ) sum up to $16$, not $12$.
Test Cases:
Imperfect:
1,12,13,18,20,1000,33550335
Perfect:
6,28,496,8128,33550336,8589869056
Rules
- Your program doesn't have to complete the larger test cases, if there's memory or time constraints, but it should be theoretically able to if it were given more memory/time.
- Output can be two distinct and consistent values through any allowed output format. If it isn't immediately obvious what represents Truthy/Falsey, please make sure to specify in your answer.
- This means your values don't have to be literally Truthy/Falsey. Your Truthy output may evaluate to false in your language and vice-versa.
code-golf number decision-problem number-theory factoring
$endgroup$
Background:
The current Perfect Numbers challenge is rather flawed and complicated, since it asks you to output in a complex format involving the factors of the number. This is a purely decision-problem repost of the challenge.
Challenge
Given a positive integer through any standard input format, output whether it is not perfect.
A perfect number is a number that is equal to the sum of all its proper divisors (its positive divisors less than itself). For example, $6$ is a perfect number, since its divisors are $1,2,3$, which sum up to $6$, while $12$ is not a perfect number since its divisors ( $1,2,3,4,6$ ) sum up to $16$, not $12$.
Test Cases:
Imperfect:
1,12,13,18,20,1000,33550335
Perfect:
6,28,496,8128,33550336,8589869056
Rules
- Your program doesn't have to complete the larger test cases, if there's memory or time constraints, but it should be theoretically able to if it were given more memory/time.
- Output can be two distinct and consistent values through any allowed output format. If it isn't immediately obvious what represents Truthy/Falsey, please make sure to specify in your answer.
- This means your values don't have to be literally Truthy/Falsey. Your Truthy output may evaluate to false in your language and vice-versa.
code-golf number decision-problem number-theory factoring
code-golf number decision-problem number-theory factoring
edited 46 mins ago
Jo King
asked 1 hour ago
Jo KingJo King
24.6k357126
24.6k357126
$begingroup$
Wait, so truthy is for values that aren't perfect, and falsey is for values that are?
$endgroup$
– Esolanging Fruit
50 mins ago
$begingroup$
@EsolangingFruit Yes, though the actual output values don't really matter, so you can output true for perfect numbers if you wish
$endgroup$
– Jo King
48 mins ago
$begingroup$
Fair enough, but wording the challenge as "output whether it is not perfect" makes the test cases slightly confusing if you interpret "truthy" as meaning "values corresponding to true".
$endgroup$
– Esolanging Fruit
47 mins ago
$begingroup$
@EsolangingFruit Good point. I've renamed the test cases toImperfect
/Perfect
to make it clearer
$endgroup$
– Jo King
45 mins ago
add a comment |
$begingroup$
Wait, so truthy is for values that aren't perfect, and falsey is for values that are?
$endgroup$
– Esolanging Fruit
50 mins ago
$begingroup$
@EsolangingFruit Yes, though the actual output values don't really matter, so you can output true for perfect numbers if you wish
$endgroup$
– Jo King
48 mins ago
$begingroup$
Fair enough, but wording the challenge as "output whether it is not perfect" makes the test cases slightly confusing if you interpret "truthy" as meaning "values corresponding to true".
$endgroup$
– Esolanging Fruit
47 mins ago
$begingroup$
@EsolangingFruit Good point. I've renamed the test cases toImperfect
/Perfect
to make it clearer
$endgroup$
– Jo King
45 mins ago
$begingroup$
Wait, so truthy is for values that aren't perfect, and falsey is for values that are?
$endgroup$
– Esolanging Fruit
50 mins ago
$begingroup$
Wait, so truthy is for values that aren't perfect, and falsey is for values that are?
$endgroup$
– Esolanging Fruit
50 mins ago
$begingroup$
@EsolangingFruit Yes, though the actual output values don't really matter, so you can output true for perfect numbers if you wish
$endgroup$
– Jo King
48 mins ago
$begingroup$
@EsolangingFruit Yes, though the actual output values don't really matter, so you can output true for perfect numbers if you wish
$endgroup$
– Jo King
48 mins ago
$begingroup$
Fair enough, but wording the challenge as "output whether it is not perfect" makes the test cases slightly confusing if you interpret "truthy" as meaning "values corresponding to true".
$endgroup$
– Esolanging Fruit
47 mins ago
$begingroup$
Fair enough, but wording the challenge as "output whether it is not perfect" makes the test cases slightly confusing if you interpret "truthy" as meaning "values corresponding to true".
$endgroup$
– Esolanging Fruit
47 mins ago
$begingroup$
@EsolangingFruit Good point. I've renamed the test cases to
Imperfect
/Perfect
to make it clearer$endgroup$
– Jo King
45 mins ago
$begingroup$
@EsolangingFruit Good point. I've renamed the test cases to
Imperfect
/Perfect
to make it clearer$endgroup$
– Jo King
45 mins ago
add a comment |
4 Answers
4
active
oldest
votes
$begingroup$
Japt -!
, 4 bytes
¥â¬x
For some reason ¦
doesnt work on tio so I need to use the -!
flag and ¥
instead
Try it online!
$endgroup$
add a comment |
$begingroup$
R, 33 bytes
!2*(n=scan())-sum(which(!n%%1:n))
Try it online!
Returns TRUE
for perfect numbers ans FALSE
for imperfect ones.
$endgroup$
$begingroup$
What do the 2 !s in a row get you?
$endgroup$
– CT Hall
30 mins ago
$begingroup$
@CTHall I misread the spec; they originally mapped0
(perfect) toFALSE
and nonzero toTRUE
but I removed one of them to reverse the mapping. It's a useful golfing trick to cast fromnumeric
tological
, often in conjunction withwhich
or[
.
$endgroup$
– Giuseppe
10 mins ago
add a comment |
$begingroup$
CJam, 17 bytes
ri_,(;{1$%!},:+=
Try it online!
$endgroup$
add a comment |
$begingroup$
Javascript, 62
n=>n==[...Array(n).keys()].filter(a=>n%a<1).reduce((a,b)=>a+b)
Explanation (although it's pretty simple)
n=> //return function that takes n
n== //and returns if n is equal to
[...Array(n).keys()] //an array [0..(n-1)]...
.filter(a=>n%a<1) //where all of the elements that are not divisors of n are taken out...
.reduce((a,b)=>a+b) //summed up
Thanks to Jo King for the improvement!
$endgroup$
$begingroup$
thanks! Added that in
$endgroup$
– zevee
44 mins ago
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
return StackExchange.using("mathjaxEditing", function () {
StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix) {
StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["\$", "\$"]]);
});
});
}, "mathjax-editing");
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "200"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodegolf.stackexchange.com%2fquestions%2f181350%2fam-i-not-good-enough-for-you%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
4 Answers
4
active
oldest
votes
4 Answers
4
active
oldest
votes
active
oldest
votes
active
oldest
votes
$begingroup$
Japt -!
, 4 bytes
¥â¬x
For some reason ¦
doesnt work on tio so I need to use the -!
flag and ¥
instead
Try it online!
$endgroup$
add a comment |
$begingroup$
Japt -!
, 4 bytes
¥â¬x
For some reason ¦
doesnt work on tio so I need to use the -!
flag and ¥
instead
Try it online!
$endgroup$
add a comment |
$begingroup$
Japt -!
, 4 bytes
¥â¬x
For some reason ¦
doesnt work on tio so I need to use the -!
flag and ¥
instead
Try it online!
$endgroup$
Japt -!
, 4 bytes
¥â¬x
For some reason ¦
doesnt work on tio so I need to use the -!
flag and ¥
instead
Try it online!
edited 48 mins ago
answered 53 mins ago
Luis felipe De jesus MunozLuis felipe De jesus Munoz
5,60821670
5,60821670
add a comment |
add a comment |
$begingroup$
R, 33 bytes
!2*(n=scan())-sum(which(!n%%1:n))
Try it online!
Returns TRUE
for perfect numbers ans FALSE
for imperfect ones.
$endgroup$
$begingroup$
What do the 2 !s in a row get you?
$endgroup$
– CT Hall
30 mins ago
$begingroup$
@CTHall I misread the spec; they originally mapped0
(perfect) toFALSE
and nonzero toTRUE
but I removed one of them to reverse the mapping. It's a useful golfing trick to cast fromnumeric
tological
, often in conjunction withwhich
or[
.
$endgroup$
– Giuseppe
10 mins ago
add a comment |
$begingroup$
R, 33 bytes
!2*(n=scan())-sum(which(!n%%1:n))
Try it online!
Returns TRUE
for perfect numbers ans FALSE
for imperfect ones.
$endgroup$
$begingroup$
What do the 2 !s in a row get you?
$endgroup$
– CT Hall
30 mins ago
$begingroup$
@CTHall I misread the spec; they originally mapped0
(perfect) toFALSE
and nonzero toTRUE
but I removed one of them to reverse the mapping. It's a useful golfing trick to cast fromnumeric
tological
, often in conjunction withwhich
or[
.
$endgroup$
– Giuseppe
10 mins ago
add a comment |
$begingroup$
R, 33 bytes
!2*(n=scan())-sum(which(!n%%1:n))
Try it online!
Returns TRUE
for perfect numbers ans FALSE
for imperfect ones.
$endgroup$
R, 33 bytes
!2*(n=scan())-sum(which(!n%%1:n))
Try it online!
Returns TRUE
for perfect numbers ans FALSE
for imperfect ones.
answered 34 mins ago
GiuseppeGiuseppe
16.8k31052
16.8k31052
$begingroup$
What do the 2 !s in a row get you?
$endgroup$
– CT Hall
30 mins ago
$begingroup$
@CTHall I misread the spec; they originally mapped0
(perfect) toFALSE
and nonzero toTRUE
but I removed one of them to reverse the mapping. It's a useful golfing trick to cast fromnumeric
tological
, often in conjunction withwhich
or[
.
$endgroup$
– Giuseppe
10 mins ago
add a comment |
$begingroup$
What do the 2 !s in a row get you?
$endgroup$
– CT Hall
30 mins ago
$begingroup$
@CTHall I misread the spec; they originally mapped0
(perfect) toFALSE
and nonzero toTRUE
but I removed one of them to reverse the mapping. It's a useful golfing trick to cast fromnumeric
tological
, often in conjunction withwhich
or[
.
$endgroup$
– Giuseppe
10 mins ago
$begingroup$
What do the 2 !s in a row get you?
$endgroup$
– CT Hall
30 mins ago
$begingroup$
What do the 2 !s in a row get you?
$endgroup$
– CT Hall
30 mins ago
$begingroup$
@CTHall I misread the spec; they originally mapped
0
(perfect) to FALSE
and nonzero to TRUE
but I removed one of them to reverse the mapping. It's a useful golfing trick to cast from numeric
to logical
, often in conjunction with which
or [
.$endgroup$
– Giuseppe
10 mins ago
$begingroup$
@CTHall I misread the spec; they originally mapped
0
(perfect) to FALSE
and nonzero to TRUE
but I removed one of them to reverse the mapping. It's a useful golfing trick to cast from numeric
to logical
, often in conjunction with which
or [
.$endgroup$
– Giuseppe
10 mins ago
add a comment |
$begingroup$
CJam, 17 bytes
ri_,(;{1$%!},:+=
Try it online!
$endgroup$
add a comment |
$begingroup$
CJam, 17 bytes
ri_,(;{1$%!},:+=
Try it online!
$endgroup$
add a comment |
$begingroup$
CJam, 17 bytes
ri_,(;{1$%!},:+=
Try it online!
$endgroup$
CJam, 17 bytes
ri_,(;{1$%!},:+=
Try it online!
answered 48 mins ago
Esolanging FruitEsolanging Fruit
8,50932674
8,50932674
add a comment |
add a comment |
$begingroup$
Javascript, 62
n=>n==[...Array(n).keys()].filter(a=>n%a<1).reduce((a,b)=>a+b)
Explanation (although it's pretty simple)
n=> //return function that takes n
n== //and returns if n is equal to
[...Array(n).keys()] //an array [0..(n-1)]...
.filter(a=>n%a<1) //where all of the elements that are not divisors of n are taken out...
.reduce((a,b)=>a+b) //summed up
Thanks to Jo King for the improvement!
$endgroup$
$begingroup$
thanks! Added that in
$endgroup$
– zevee
44 mins ago
add a comment |
$begingroup$
Javascript, 62
n=>n==[...Array(n).keys()].filter(a=>n%a<1).reduce((a,b)=>a+b)
Explanation (although it's pretty simple)
n=> //return function that takes n
n== //and returns if n is equal to
[...Array(n).keys()] //an array [0..(n-1)]...
.filter(a=>n%a<1) //where all of the elements that are not divisors of n are taken out...
.reduce((a,b)=>a+b) //summed up
Thanks to Jo King for the improvement!
$endgroup$
$begingroup$
thanks! Added that in
$endgroup$
– zevee
44 mins ago
add a comment |
$begingroup$
Javascript, 62
n=>n==[...Array(n).keys()].filter(a=>n%a<1).reduce((a,b)=>a+b)
Explanation (although it's pretty simple)
n=> //return function that takes n
n== //and returns if n is equal to
[...Array(n).keys()] //an array [0..(n-1)]...
.filter(a=>n%a<1) //where all of the elements that are not divisors of n are taken out...
.reduce((a,b)=>a+b) //summed up
Thanks to Jo King for the improvement!
$endgroup$
Javascript, 62
n=>n==[...Array(n).keys()].filter(a=>n%a<1).reduce((a,b)=>a+b)
Explanation (although it's pretty simple)
n=> //return function that takes n
n== //and returns if n is equal to
[...Array(n).keys()] //an array [0..(n-1)]...
.filter(a=>n%a<1) //where all of the elements that are not divisors of n are taken out...
.reduce((a,b)=>a+b) //summed up
Thanks to Jo King for the improvement!
edited 44 mins ago
answered 52 mins ago
zeveezevee
22016
22016
$begingroup$
thanks! Added that in
$endgroup$
– zevee
44 mins ago
add a comment |
$begingroup$
thanks! Added that in
$endgroup$
– zevee
44 mins ago
$begingroup$
thanks! Added that in
$endgroup$
– zevee
44 mins ago
$begingroup$
thanks! Added that in
$endgroup$
– zevee
44 mins ago
add a comment |
If this is an answer to a challenge…
…Be sure to follow the challenge specification. However, please refrain from exploiting obvious loopholes. Answers abusing any of the standard loopholes are considered invalid. If you think a specification is unclear or underspecified, comment on the question instead.
…Try to optimize your score. For instance, answers to code-golf challenges should attempt to be as short as possible. You can always include a readable version of the code in addition to the competitive one.
Explanations of your answer make it more interesting to read and are very much encouraged.…Include a short header which indicates the language(s) of your code and its score, as defined by the challenge.
More generally…
…Please make sure to answer the question and provide sufficient detail.
…Avoid asking for help, clarification or responding to other answers (use comments instead).
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodegolf.stackexchange.com%2fquestions%2f181350%2fam-i-not-good-enough-for-you%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
$begingroup$
Wait, so truthy is for values that aren't perfect, and falsey is for values that are?
$endgroup$
– Esolanging Fruit
50 mins ago
$begingroup$
@EsolangingFruit Yes, though the actual output values don't really matter, so you can output true for perfect numbers if you wish
$endgroup$
– Jo King
48 mins ago
$begingroup$
Fair enough, but wording the challenge as "output whether it is not perfect" makes the test cases slightly confusing if you interpret "truthy" as meaning "values corresponding to true".
$endgroup$
– Esolanging Fruit
47 mins ago
$begingroup$
@EsolangingFruit Good point. I've renamed the test cases to
Imperfect
/Perfect
to make it clearer$endgroup$
– Jo King
45 mins ago