Am I not good enough for you?












5












$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, distinguish between whether it is perfect or not.



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 Perfect/Imperfect, please make sure to specify in your answer.










share|improve this question











$endgroup$












  • $begingroup$
    Wait, so truthy is for values that aren't perfect, and falsey is for values that are?
    $endgroup$
    – Esolanging Fruit
    3 hours 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
    3 hours 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
    3 hours ago










  • $begingroup$
    @EsolangingFruit Good point. I've renamed the test cases to Imperfect/Perfect to make it clearer
    $endgroup$
    – Jo King
    3 hours ago
















5












$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, distinguish between whether it is perfect or not.



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 Perfect/Imperfect, please make sure to specify in your answer.










share|improve this question











$endgroup$












  • $begingroup$
    Wait, so truthy is for values that aren't perfect, and falsey is for values that are?
    $endgroup$
    – Esolanging Fruit
    3 hours 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
    3 hours 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
    3 hours ago










  • $begingroup$
    @EsolangingFruit Good point. I've renamed the test cases to Imperfect/Perfect to make it clearer
    $endgroup$
    – Jo King
    3 hours ago














5












5








5





$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, distinguish between whether it is perfect or not.



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 Perfect/Imperfect, please make sure to specify in your answer.










share|improve this question











$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, distinguish between whether it is perfect or not.



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 Perfect/Imperfect, please make sure to specify in your answer.







code-golf number decision-problem number-theory factoring






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 2 hours ago







Jo King

















asked 4 hours 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
    3 hours 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
    3 hours 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
    3 hours ago










  • $begingroup$
    @EsolangingFruit Good point. I've renamed the test cases to Imperfect/Perfect to make it clearer
    $endgroup$
    – Jo King
    3 hours ago


















  • $begingroup$
    Wait, so truthy is for values that aren't perfect, and falsey is for values that are?
    $endgroup$
    – Esolanging Fruit
    3 hours 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
    3 hours 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
    3 hours ago










  • $begingroup$
    @EsolangingFruit Good point. I've renamed the test cases to Imperfect/Perfect to make it clearer
    $endgroup$
    – Jo King
    3 hours ago
















$begingroup$
Wait, so truthy is for values that aren't perfect, and falsey is for values that are?
$endgroup$
– Esolanging Fruit
3 hours ago




$begingroup$
Wait, so truthy is for values that aren't perfect, and falsey is for values that are?
$endgroup$
– Esolanging Fruit
3 hours 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
3 hours 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
3 hours 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
3 hours 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
3 hours ago












$begingroup$
@EsolangingFruit Good point. I've renamed the test cases to Imperfect/Perfect to make it clearer
$endgroup$
– Jo King
3 hours ago




$begingroup$
@EsolangingFruit Good point. I've renamed the test cases to Imperfect/Perfect to make it clearer
$endgroup$
– Jo King
3 hours ago










10 Answers
10






active

oldest

votes


















4












$begingroup$


Japt -!, 4 bytes



¥â¬x


For some reason ¦ doesnt work on tio so I need to use the -! flag and ¥ instead



Try it online!






share|improve this answer











$endgroup$





















    4












    $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.






    share|improve this answer









    $endgroup$













    • $begingroup$
      What do the 2 !s in a row get you?
      $endgroup$
      – CT Hall
      3 hours 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
      3 hours ago





















    3












    $begingroup$


    Python 3, 46 bytes





    lambda x:sum(i for i in range(1,x)if x%i<1)==x


    Try it online!



    Brute force, sums the factors and checks for equality.






    share|improve this answer











    $endgroup$













    • $begingroup$
      Yeah, that was a typo. I'll fix it now.
      $endgroup$
      – Neil A.
      2 hours ago








    • 1




      $begingroup$
      Using the comprehension condition as a mask for your iteration variable would save a byte.
      $endgroup$
      – Jonathan Frech
      2 hours ago



















    3












    $begingroup$


    Jelly, 3 bytes



    Æṣ=


    Try it online!






    share|improve this answer









    $endgroup$





















      2












      $begingroup$


      CJam, 17 bytes



      ri_,(;{1$%!},:+=


      Try it online!






      share|improve this answer









      $endgroup$





















        2












        $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!






        share|improve this answer











        $endgroup$













        • $begingroup$
          thanks! Added that in
          $endgroup$
          – zevee
          3 hours ago



















        2












        $begingroup$


        C# (Visual C# Interactive Compiler), 49 47 bytes





        n=>Enumerable.Range(1,n).Sum(x=>n%x<1?x:0)==n*2


        Try it online!






        share|improve this answer











        $endgroup$





















          2












          $begingroup$


          Brachylog, 4 bytes



          fk+?


          Try it online!



          The predicate succeeds for perfect inputs and fails for imperfect inputs, printing true. or false. if run as a complete program (except on the last test case which takes more than a minute on TIO).



                  The input's
          f factors
          k without the last element
          + sum to
          ? the input.





          share|improve this answer









          $endgroup$





















            1












            $begingroup$


            Neim, 3 bytes



            𝐕𝐬𝔼


            Try it online!



            (I don't actually know how to run all of the test cases at once, since I started learning Neim about fifteen minutes ago, but I did check them individually.)



            Prints 0 for imperfect, 1 for perfect.



            𝐕      Pop an int from the stack and push its proper divisors,
            implicitly reading the int from a line of input as the otherwise absent top of the stack.
            𝐬 Pop a list from the stack and push the sum of the values it contains.
            𝔼 Pop two ints from the stack and push 1 if they are equal, 0 if they are not;
            implicitly reading the same line of input that was already read as the second int, I guess?
            Implicitly print the contents of the stack, or something like that.





            share|improve this answer









            $endgroup$





















              1












              $begingroup$

              JavaScript, 40 bytes





              f=n=>eval("for(i=s=n;--i;)n%i||!(s-=i)")


              Try it online!



              (Last testcase timeout on TIO.)






              share|improve this answer











              $endgroup$













                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
                });


                }
                });














                draft saved

                draft discarded


















                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

























                10 Answers
                10






                active

                oldest

                votes








                10 Answers
                10






                active

                oldest

                votes









                active

                oldest

                votes






                active

                oldest

                votes









                4












                $begingroup$


                Japt -!, 4 bytes



                ¥â¬x


                For some reason ¦ doesnt work on tio so I need to use the -! flag and ¥ instead



                Try it online!






                share|improve this answer











                $endgroup$


















                  4












                  $begingroup$


                  Japt -!, 4 bytes



                  ¥â¬x


                  For some reason ¦ doesnt work on tio so I need to use the -! flag and ¥ instead



                  Try it online!






                  share|improve this answer











                  $endgroup$
















                    4












                    4








                    4





                    $begingroup$


                    Japt -!, 4 bytes



                    ¥â¬x


                    For some reason ¦ doesnt work on tio so I need to use the -! flag and ¥ instead



                    Try it online!






                    share|improve this answer











                    $endgroup$




                    Japt -!, 4 bytes



                    ¥â¬x


                    For some reason ¦ doesnt work on tio so I need to use the -! flag and ¥ instead



                    Try it online!







                    share|improve this answer














                    share|improve this answer



                    share|improve this answer








                    edited 3 hours ago

























                    answered 4 hours ago









                    Luis felipe De jesus MunozLuis felipe De jesus Munoz

                    5,61821670




                    5,61821670























                        4












                        $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.






                        share|improve this answer









                        $endgroup$













                        • $begingroup$
                          What do the 2 !s in a row get you?
                          $endgroup$
                          – CT Hall
                          3 hours 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
                          3 hours ago


















                        4












                        $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.






                        share|improve this answer









                        $endgroup$













                        • $begingroup$
                          What do the 2 !s in a row get you?
                          $endgroup$
                          – CT Hall
                          3 hours 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
                          3 hours ago
















                        4












                        4








                        4





                        $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.






                        share|improve this answer









                        $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.







                        share|improve this answer












                        share|improve this answer



                        share|improve this answer










                        answered 3 hours ago









                        GiuseppeGiuseppe

                        16.8k31052




                        16.8k31052












                        • $begingroup$
                          What do the 2 !s in a row get you?
                          $endgroup$
                          – CT Hall
                          3 hours 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
                          3 hours ago




















                        • $begingroup$
                          What do the 2 !s in a row get you?
                          $endgroup$
                          – CT Hall
                          3 hours 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
                          3 hours ago


















                        $begingroup$
                        What do the 2 !s in a row get you?
                        $endgroup$
                        – CT Hall
                        3 hours ago




                        $begingroup$
                        What do the 2 !s in a row get you?
                        $endgroup$
                        – CT Hall
                        3 hours 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
                        3 hours 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
                        3 hours ago













                        3












                        $begingroup$


                        Python 3, 46 bytes





                        lambda x:sum(i for i in range(1,x)if x%i<1)==x


                        Try it online!



                        Brute force, sums the factors and checks for equality.






                        share|improve this answer











                        $endgroup$













                        • $begingroup$
                          Yeah, that was a typo. I'll fix it now.
                          $endgroup$
                          – Neil A.
                          2 hours ago








                        • 1




                          $begingroup$
                          Using the comprehension condition as a mask for your iteration variable would save a byte.
                          $endgroup$
                          – Jonathan Frech
                          2 hours ago
















                        3












                        $begingroup$


                        Python 3, 46 bytes





                        lambda x:sum(i for i in range(1,x)if x%i<1)==x


                        Try it online!



                        Brute force, sums the factors and checks for equality.






                        share|improve this answer











                        $endgroup$













                        • $begingroup$
                          Yeah, that was a typo. I'll fix it now.
                          $endgroup$
                          – Neil A.
                          2 hours ago








                        • 1




                          $begingroup$
                          Using the comprehension condition as a mask for your iteration variable would save a byte.
                          $endgroup$
                          – Jonathan Frech
                          2 hours ago














                        3












                        3








                        3





                        $begingroup$


                        Python 3, 46 bytes





                        lambda x:sum(i for i in range(1,x)if x%i<1)==x


                        Try it online!



                        Brute force, sums the factors and checks for equality.






                        share|improve this answer











                        $endgroup$




                        Python 3, 46 bytes





                        lambda x:sum(i for i in range(1,x)if x%i<1)==x


                        Try it online!



                        Brute force, sums the factors and checks for equality.







                        share|improve this answer














                        share|improve this answer



                        share|improve this answer








                        edited 2 hours ago

























                        answered 2 hours ago









                        Neil A.Neil A.

                        1,298120




                        1,298120












                        • $begingroup$
                          Yeah, that was a typo. I'll fix it now.
                          $endgroup$
                          – Neil A.
                          2 hours ago








                        • 1




                          $begingroup$
                          Using the comprehension condition as a mask for your iteration variable would save a byte.
                          $endgroup$
                          – Jonathan Frech
                          2 hours ago


















                        • $begingroup$
                          Yeah, that was a typo. I'll fix it now.
                          $endgroup$
                          – Neil A.
                          2 hours ago








                        • 1




                          $begingroup$
                          Using the comprehension condition as a mask for your iteration variable would save a byte.
                          $endgroup$
                          – Jonathan Frech
                          2 hours ago
















                        $begingroup$
                        Yeah, that was a typo. I'll fix it now.
                        $endgroup$
                        – Neil A.
                        2 hours ago






                        $begingroup$
                        Yeah, that was a typo. I'll fix it now.
                        $endgroup$
                        – Neil A.
                        2 hours ago






                        1




                        1




                        $begingroup$
                        Using the comprehension condition as a mask for your iteration variable would save a byte.
                        $endgroup$
                        – Jonathan Frech
                        2 hours ago




                        $begingroup$
                        Using the comprehension condition as a mask for your iteration variable would save a byte.
                        $endgroup$
                        – Jonathan Frech
                        2 hours ago











                        3












                        $begingroup$


                        Jelly, 3 bytes



                        Æṣ=


                        Try it online!






                        share|improve this answer









                        $endgroup$


















                          3












                          $begingroup$


                          Jelly, 3 bytes



                          Æṣ=


                          Try it online!






                          share|improve this answer









                          $endgroup$
















                            3












                            3








                            3





                            $begingroup$


                            Jelly, 3 bytes



                            Æṣ=


                            Try it online!






                            share|improve this answer









                            $endgroup$




                            Jelly, 3 bytes



                            Æṣ=


                            Try it online!







                            share|improve this answer












                            share|improve this answer



                            share|improve this answer










                            answered 2 hours ago









                            Mr. XcoderMr. Xcoder

                            32.1k759199




                            32.1k759199























                                2












                                $begingroup$


                                CJam, 17 bytes



                                ri_,(;{1$%!},:+=


                                Try it online!






                                share|improve this answer









                                $endgroup$


















                                  2












                                  $begingroup$


                                  CJam, 17 bytes



                                  ri_,(;{1$%!},:+=


                                  Try it online!






                                  share|improve this answer









                                  $endgroup$
















                                    2












                                    2








                                    2





                                    $begingroup$


                                    CJam, 17 bytes



                                    ri_,(;{1$%!},:+=


                                    Try it online!






                                    share|improve this answer









                                    $endgroup$




                                    CJam, 17 bytes



                                    ri_,(;{1$%!},:+=


                                    Try it online!







                                    share|improve this answer












                                    share|improve this answer



                                    share|improve this answer










                                    answered 3 hours ago









                                    Esolanging FruitEsolanging Fruit

                                    8,51932674




                                    8,51932674























                                        2












                                        $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!






                                        share|improve this answer











                                        $endgroup$













                                        • $begingroup$
                                          thanks! Added that in
                                          $endgroup$
                                          – zevee
                                          3 hours ago
















                                        2












                                        $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!






                                        share|improve this answer











                                        $endgroup$













                                        • $begingroup$
                                          thanks! Added that in
                                          $endgroup$
                                          – zevee
                                          3 hours ago














                                        2












                                        2








                                        2





                                        $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!






                                        share|improve this answer











                                        $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!







                                        share|improve this answer














                                        share|improve this answer



                                        share|improve this answer








                                        edited 3 hours ago

























                                        answered 3 hours ago









                                        zeveezevee

                                        23016




                                        23016












                                        • $begingroup$
                                          thanks! Added that in
                                          $endgroup$
                                          – zevee
                                          3 hours ago


















                                        • $begingroup$
                                          thanks! Added that in
                                          $endgroup$
                                          – zevee
                                          3 hours ago
















                                        $begingroup$
                                        thanks! Added that in
                                        $endgroup$
                                        – zevee
                                        3 hours ago




                                        $begingroup$
                                        thanks! Added that in
                                        $endgroup$
                                        – zevee
                                        3 hours ago











                                        2












                                        $begingroup$


                                        C# (Visual C# Interactive Compiler), 49 47 bytes





                                        n=>Enumerable.Range(1,n).Sum(x=>n%x<1?x:0)==n*2


                                        Try it online!






                                        share|improve this answer











                                        $endgroup$


















                                          2












                                          $begingroup$


                                          C# (Visual C# Interactive Compiler), 49 47 bytes





                                          n=>Enumerable.Range(1,n).Sum(x=>n%x<1?x:0)==n*2


                                          Try it online!






                                          share|improve this answer











                                          $endgroup$
















                                            2












                                            2








                                            2





                                            $begingroup$


                                            C# (Visual C# Interactive Compiler), 49 47 bytes





                                            n=>Enumerable.Range(1,n).Sum(x=>n%x<1?x:0)==n*2


                                            Try it online!






                                            share|improve this answer











                                            $endgroup$




                                            C# (Visual C# Interactive Compiler), 49 47 bytes





                                            n=>Enumerable.Range(1,n).Sum(x=>n%x<1?x:0)==n*2


                                            Try it online!







                                            share|improve this answer














                                            share|improve this answer



                                            share|improve this answer








                                            edited 2 hours ago

























                                            answered 3 hours ago









                                            Embodiment of IgnoranceEmbodiment of Ignorance

                                            1,598124




                                            1,598124























                                                2












                                                $begingroup$


                                                Brachylog, 4 bytes



                                                fk+?


                                                Try it online!



                                                The predicate succeeds for perfect inputs and fails for imperfect inputs, printing true. or false. if run as a complete program (except on the last test case which takes more than a minute on TIO).



                                                        The input's
                                                f factors
                                                k without the last element
                                                + sum to
                                                ? the input.





                                                share|improve this answer









                                                $endgroup$


















                                                  2












                                                  $begingroup$


                                                  Brachylog, 4 bytes



                                                  fk+?


                                                  Try it online!



                                                  The predicate succeeds for perfect inputs and fails for imperfect inputs, printing true. or false. if run as a complete program (except on the last test case which takes more than a minute on TIO).



                                                          The input's
                                                  f factors
                                                  k without the last element
                                                  + sum to
                                                  ? the input.





                                                  share|improve this answer









                                                  $endgroup$
















                                                    2












                                                    2








                                                    2





                                                    $begingroup$


                                                    Brachylog, 4 bytes



                                                    fk+?


                                                    Try it online!



                                                    The predicate succeeds for perfect inputs and fails for imperfect inputs, printing true. or false. if run as a complete program (except on the last test case which takes more than a minute on TIO).



                                                            The input's
                                                    f factors
                                                    k without the last element
                                                    + sum to
                                                    ? the input.





                                                    share|improve this answer









                                                    $endgroup$




                                                    Brachylog, 4 bytes



                                                    fk+?


                                                    Try it online!



                                                    The predicate succeeds for perfect inputs and fails for imperfect inputs, printing true. or false. if run as a complete program (except on the last test case which takes more than a minute on TIO).



                                                            The input's
                                                    f factors
                                                    k without the last element
                                                    + sum to
                                                    ? the input.






                                                    share|improve this answer












                                                    share|improve this answer



                                                    share|improve this answer










                                                    answered 2 hours ago









                                                    Unrelated StringUnrelated String

                                                    93118




                                                    93118























                                                        1












                                                        $begingroup$


                                                        Neim, 3 bytes



                                                        𝐕𝐬𝔼


                                                        Try it online!



                                                        (I don't actually know how to run all of the test cases at once, since I started learning Neim about fifteen minutes ago, but I did check them individually.)



                                                        Prints 0 for imperfect, 1 for perfect.



                                                        𝐕      Pop an int from the stack and push its proper divisors,
                                                        implicitly reading the int from a line of input as the otherwise absent top of the stack.
                                                        𝐬 Pop a list from the stack and push the sum of the values it contains.
                                                        𝔼 Pop two ints from the stack and push 1 if they are equal, 0 if they are not;
                                                        implicitly reading the same line of input that was already read as the second int, I guess?
                                                        Implicitly print the contents of the stack, or something like that.





                                                        share|improve this answer









                                                        $endgroup$


















                                                          1












                                                          $begingroup$


                                                          Neim, 3 bytes



                                                          𝐕𝐬𝔼


                                                          Try it online!



                                                          (I don't actually know how to run all of the test cases at once, since I started learning Neim about fifteen minutes ago, but I did check them individually.)



                                                          Prints 0 for imperfect, 1 for perfect.



                                                          𝐕      Pop an int from the stack and push its proper divisors,
                                                          implicitly reading the int from a line of input as the otherwise absent top of the stack.
                                                          𝐬 Pop a list from the stack and push the sum of the values it contains.
                                                          𝔼 Pop two ints from the stack and push 1 if they are equal, 0 if they are not;
                                                          implicitly reading the same line of input that was already read as the second int, I guess?
                                                          Implicitly print the contents of the stack, or something like that.





                                                          share|improve this answer









                                                          $endgroup$
















                                                            1












                                                            1








                                                            1





                                                            $begingroup$


                                                            Neim, 3 bytes



                                                            𝐕𝐬𝔼


                                                            Try it online!



                                                            (I don't actually know how to run all of the test cases at once, since I started learning Neim about fifteen minutes ago, but I did check them individually.)



                                                            Prints 0 for imperfect, 1 for perfect.



                                                            𝐕      Pop an int from the stack and push its proper divisors,
                                                            implicitly reading the int from a line of input as the otherwise absent top of the stack.
                                                            𝐬 Pop a list from the stack and push the sum of the values it contains.
                                                            𝔼 Pop two ints from the stack and push 1 if they are equal, 0 if they are not;
                                                            implicitly reading the same line of input that was already read as the second int, I guess?
                                                            Implicitly print the contents of the stack, or something like that.





                                                            share|improve this answer









                                                            $endgroup$




                                                            Neim, 3 bytes



                                                            𝐕𝐬𝔼


                                                            Try it online!



                                                            (I don't actually know how to run all of the test cases at once, since I started learning Neim about fifteen minutes ago, but I did check them individually.)



                                                            Prints 0 for imperfect, 1 for perfect.



                                                            𝐕      Pop an int from the stack and push its proper divisors,
                                                            implicitly reading the int from a line of input as the otherwise absent top of the stack.
                                                            𝐬 Pop a list from the stack and push the sum of the values it contains.
                                                            𝔼 Pop two ints from the stack and push 1 if they are equal, 0 if they are not;
                                                            implicitly reading the same line of input that was already read as the second int, I guess?
                                                            Implicitly print the contents of the stack, or something like that.






                                                            share|improve this answer












                                                            share|improve this answer



                                                            share|improve this answer










                                                            answered 2 hours ago









                                                            Unrelated StringUnrelated String

                                                            93118




                                                            93118























                                                                1












                                                                $begingroup$

                                                                JavaScript, 40 bytes





                                                                f=n=>eval("for(i=s=n;--i;)n%i||!(s-=i)")


                                                                Try it online!



                                                                (Last testcase timeout on TIO.)






                                                                share|improve this answer











                                                                $endgroup$


















                                                                  1












                                                                  $begingroup$

                                                                  JavaScript, 40 bytes





                                                                  f=n=>eval("for(i=s=n;--i;)n%i||!(s-=i)")


                                                                  Try it online!



                                                                  (Last testcase timeout on TIO.)






                                                                  share|improve this answer











                                                                  $endgroup$
















                                                                    1












                                                                    1








                                                                    1





                                                                    $begingroup$

                                                                    JavaScript, 40 bytes





                                                                    f=n=>eval("for(i=s=n;--i;)n%i||!(s-=i)")


                                                                    Try it online!



                                                                    (Last testcase timeout on TIO.)






                                                                    share|improve this answer











                                                                    $endgroup$



                                                                    JavaScript, 40 bytes





                                                                    f=n=>eval("for(i=s=n;--i;)n%i||!(s-=i)")


                                                                    Try it online!



                                                                    (Last testcase timeout on TIO.)







                                                                    share|improve this answer














                                                                    share|improve this answer



                                                                    share|improve this answer








                                                                    edited 1 min ago

























                                                                    answered 21 mins ago









                                                                    tshtsh

                                                                    9,41511652




                                                                    9,41511652






























                                                                        draft saved

                                                                        draft discarded




















































                                                                        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).





                                                                        draft saved


                                                                        draft discarded














                                                                        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





















































                                                                        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







                                                                        Popular posts from this blog

                                                                        GameSpot

                                                                        connect to host localhost port 22: Connection refused

                                                                        Getting a Wifi WPA2 wifi connection