The Nth Gryphon Number Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 23, 2019 at 00:00UTC (8:00pm US/Eastern) The PPCG Site design is on its way - help us make it awesome! Sandbox for Proposed ChallengesReturn the nth digit of the sequence of aliquot seriesOutput the nth rational number according to the Stern-Brocot sequenceNumbers divisible by the sum and product of their digitsDisplay OEIS sequencesLinear interpolation of the Fibonacci sequenceSwap the SequenceSeeking Secret Swapping SequencesCan even numbers become prime?Back to the Basics of MathX Steps Forward, 1 Step Back

One-one communication

What is the meaning of 'breadth' in breadth first search?

AppleTVs create a chatty alternate WiFi network

Is there hard evidence that the grant peer review system performs significantly better than random?

How would a mousetrap for use in space work?

How fail-safe is nr as stop bytes?

Is there any word for a place full of confusion?

What would you call this weird metallic apparatus that allows you to lift people?

Why is there Net Work Done on a Pressure/Volume Cycle?

Can you explain what "processes and tools" means in the first Agile principle?

Project Euler #1 in C++

Importance of からだ in this sentence

How to play a character with a disability or mental disorder without being offensive?

What do you call the main part of a joke?

A letter with no particular backstory

"Lost his faith in humanity in the trenches of Verdun" — last line of an SF story

Do wooden building fires get hotter than 600°C?

Why weren't discrete x86 CPUs ever used in game hardware?

Is it possible for SQL statements to execute concurrently within a single session in SQL Server?

Why limits give us the exact value of the slope of the tangent line?

How to run automated tests after each commit?

Electrolysis of water: Which equations to use? (IB Chem)

Belief In God or Knowledge Of God. Which is better?

Who can remove European Commissioners?



The Nth Gryphon Number



Announcing the arrival of Valued Associate #679: Cesar Manara
Planned maintenance scheduled April 23, 2019 at 00:00UTC (8:00pm US/Eastern)
The PPCG Site design is on its way - help us make it awesome!
Sandbox for Proposed ChallengesReturn the nth digit of the sequence of aliquot seriesOutput the nth rational number according to the Stern-Brocot sequenceNumbers divisible by the sum and product of their digitsDisplay OEIS sequencesLinear interpolation of the Fibonacci sequenceSwap the SequenceSeeking Secret Swapping SequencesCan even numbers become prime?Back to the Basics of MathX Steps Forward, 1 Step Back










8












$begingroup$


I came up with a series of numbers the other day and decided to check what the OEIS number for it was. Much to my surprise, the sequence did not appear to be in the OEIS database, so I decided to name the sequence after myself (note that someone else who's a lot smarter than me has probably already come up with this, and if someone finds the actual name of this sequence, please comment and I'll change the question title). As I couldn't find the sequence anywhere, I decided to name it after myself, hence "Gryphon Numbers".



A Gryphon number is a number of the form $a+a^2+...+a^x$, where both $a$ and $x$ are integers greater than or equal to two, and the Gryphon sequence is the set of all Gryphon numbers in ascending order. If there are multiple ways of forming a Gryphon number (the first example is $30$, which is both $2+2^2+2^3+2^4$ and $5+5^2$) the number is only counted once in the sequence. The first few Gryphon numbers are: $6, 12, 14, 20, 30, 39, 42, 56, 62, 72$.



Your Task:



Write a program or function that receives an integer $n$ as input and outputs the $n$th Gryphon number.



Input:



An integer between 0 and 10000 (inclusive). You may treat the sequence as either 0-indexed or 1-indexed, whichever you prefer. Please state which indexing system you use in your answer to avoid confusion.



Output:



The Gryphon number corresponding to the input.



Test Cases:



Please note that this assumes the sequence is 0-indexed. If your program assumes a 1-indexed sequence, don't forget to increment all the input numbers.



Input: Output:
0 ---> 6
3 ---> 20
4 ---> 30
10 ---> 84


Scoring:



This is code-golf, so the lowest score in bytes wins.










share|improve this question











$endgroup$







  • 3




    $begingroup$
    How about bigger test cases like 2000 or 10000?
    $endgroup$
    – J42161217
    1 hour ago















8












$begingroup$


I came up with a series of numbers the other day and decided to check what the OEIS number for it was. Much to my surprise, the sequence did not appear to be in the OEIS database, so I decided to name the sequence after myself (note that someone else who's a lot smarter than me has probably already come up with this, and if someone finds the actual name of this sequence, please comment and I'll change the question title). As I couldn't find the sequence anywhere, I decided to name it after myself, hence "Gryphon Numbers".



A Gryphon number is a number of the form $a+a^2+...+a^x$, where both $a$ and $x$ are integers greater than or equal to two, and the Gryphon sequence is the set of all Gryphon numbers in ascending order. If there are multiple ways of forming a Gryphon number (the first example is $30$, which is both $2+2^2+2^3+2^4$ and $5+5^2$) the number is only counted once in the sequence. The first few Gryphon numbers are: $6, 12, 14, 20, 30, 39, 42, 56, 62, 72$.



Your Task:



Write a program or function that receives an integer $n$ as input and outputs the $n$th Gryphon number.



Input:



An integer between 0 and 10000 (inclusive). You may treat the sequence as either 0-indexed or 1-indexed, whichever you prefer. Please state which indexing system you use in your answer to avoid confusion.



Output:



The Gryphon number corresponding to the input.



Test Cases:



Please note that this assumes the sequence is 0-indexed. If your program assumes a 1-indexed sequence, don't forget to increment all the input numbers.



Input: Output:
0 ---> 6
3 ---> 20
4 ---> 30
10 ---> 84


Scoring:



This is code-golf, so the lowest score in bytes wins.










share|improve this question











$endgroup$







  • 3




    $begingroup$
    How about bigger test cases like 2000 or 10000?
    $endgroup$
    – J42161217
    1 hour ago













8












8








8





$begingroup$


I came up with a series of numbers the other day and decided to check what the OEIS number for it was. Much to my surprise, the sequence did not appear to be in the OEIS database, so I decided to name the sequence after myself (note that someone else who's a lot smarter than me has probably already come up with this, and if someone finds the actual name of this sequence, please comment and I'll change the question title). As I couldn't find the sequence anywhere, I decided to name it after myself, hence "Gryphon Numbers".



A Gryphon number is a number of the form $a+a^2+...+a^x$, where both $a$ and $x$ are integers greater than or equal to two, and the Gryphon sequence is the set of all Gryphon numbers in ascending order. If there are multiple ways of forming a Gryphon number (the first example is $30$, which is both $2+2^2+2^3+2^4$ and $5+5^2$) the number is only counted once in the sequence. The first few Gryphon numbers are: $6, 12, 14, 20, 30, 39, 42, 56, 62, 72$.



Your Task:



Write a program or function that receives an integer $n$ as input and outputs the $n$th Gryphon number.



Input:



An integer between 0 and 10000 (inclusive). You may treat the sequence as either 0-indexed or 1-indexed, whichever you prefer. Please state which indexing system you use in your answer to avoid confusion.



Output:



The Gryphon number corresponding to the input.



Test Cases:



Please note that this assumes the sequence is 0-indexed. If your program assumes a 1-indexed sequence, don't forget to increment all the input numbers.



Input: Output:
0 ---> 6
3 ---> 20
4 ---> 30
10 ---> 84


Scoring:



This is code-golf, so the lowest score in bytes wins.










share|improve this question











$endgroup$




I came up with a series of numbers the other day and decided to check what the OEIS number for it was. Much to my surprise, the sequence did not appear to be in the OEIS database, so I decided to name the sequence after myself (note that someone else who's a lot smarter than me has probably already come up with this, and if someone finds the actual name of this sequence, please comment and I'll change the question title). As I couldn't find the sequence anywhere, I decided to name it after myself, hence "Gryphon Numbers".



A Gryphon number is a number of the form $a+a^2+...+a^x$, where both $a$ and $x$ are integers greater than or equal to two, and the Gryphon sequence is the set of all Gryphon numbers in ascending order. If there are multiple ways of forming a Gryphon number (the first example is $30$, which is both $2+2^2+2^3+2^4$ and $5+5^2$) the number is only counted once in the sequence. The first few Gryphon numbers are: $6, 12, 14, 20, 30, 39, 42, 56, 62, 72$.



Your Task:



Write a program or function that receives an integer $n$ as input and outputs the $n$th Gryphon number.



Input:



An integer between 0 and 10000 (inclusive). You may treat the sequence as either 0-indexed or 1-indexed, whichever you prefer. Please state which indexing system you use in your answer to avoid confusion.



Output:



The Gryphon number corresponding to the input.



Test Cases:



Please note that this assumes the sequence is 0-indexed. If your program assumes a 1-indexed sequence, don't forget to increment all the input numbers.



Input: Output:
0 ---> 6
3 ---> 20
4 ---> 30
10 ---> 84


Scoring:



This is code-golf, so the lowest score in bytes wins.







code-golf sequence






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 1 hour ago









Giuseppe

17.9k31155




17.9k31155










asked 1 hour ago









GryphonGryphon

3,57912165




3,57912165







  • 3




    $begingroup$
    How about bigger test cases like 2000 or 10000?
    $endgroup$
    – J42161217
    1 hour ago












  • 3




    $begingroup$
    How about bigger test cases like 2000 or 10000?
    $endgroup$
    – J42161217
    1 hour ago







3




3




$begingroup$
How about bigger test cases like 2000 or 10000?
$endgroup$
– J42161217
1 hour ago




$begingroup$
How about bigger test cases like 2000 or 10000?
$endgroup$
– J42161217
1 hour ago










5 Answers
5






active

oldest

votes


















4












$begingroup$


MATL, 16 13 bytes



:Qtt!^Ys+uSG)


1-based.



Try it online!



Explanation



Consider input n = 3 as an example.



: % Implicit input: n. Range
% STACK: [1 2 3]
Q % Add 1, element-wise
% STACK: [2 3 4]
tt % Duplicate twice, transpose
% STACK: [2 3 4], [2 3 4], [2;
3;
4]
^ % Power, element-wise with broadcast
% STACK: [2 3 4], [ 4 9 16;
8 27 64;
16 81 256]
Ys % Cumulative sum of each column
% STACK: [2 3 4], [ 4 9 16;
12 36 80;
28 117 336]
+ % Add, element-wise with broadcast (*)
% STACK: [ 6 12 20;
14 39 84
30 120 340]
u % Unique elements. Gives a column vector
% STACK: [ 6;
14;
30;
12;
···
340]
S % Sort
% STACK: [ 6;
12
14;
20;
···
340]
G) % Push input again, index. This gets the n-th element. Implicit display
% STACK: 14


The matrix obtained in step (*) contains possibly repeated Gryphon numbers. In particular, it contains n distinct Gryphon numbers in its first row. These are not necessarily the n smallest Gryphon numbers. However, the lower-left entry 2+2^+···+2^n exceeds the upper-right entry n+n^2, and thus all the numbers in the last row exceed those in the first row. This implies that extending the matrix rightward or downward would not contribute any Gryphon number lower than the lowest n numbers in the matrix. Therefore, the matrix is guaranteed to contain the n smallest Gryphon numbers. Consequently, its n-th lowest unique element is the solution.






share|improve this answer











$endgroup$








  • 1




    $begingroup$
    What the hell, this is amazing!
    $endgroup$
    – IQuick 143
    59 mins ago


















1












$begingroup$


Wolfram Language (Mathematica), 59 bytes



Union[Join@@Table[Sum[n^k,k,j],j,2,30,n,2,7!2]][[#]]&


Try it online!



1-indexed






share|improve this answer









$endgroup$




















    1












    $begingroup$


    Jelly, 9 bytes



    bṖ’ḅi-µ#Ṫ


    A full program which reads a (1-indexed) integer from STDIN and prints the result.



    Try it online!



    How?



    A Gryphon number is a number which is expressible in a base less than itself such that all the digits are ones except the least significant, which is a zero. For example:



    $30=1times 2^4+1times 2^3+1times2^2+1times2^1+0times2^0$



    $84=1times 4^3+1times 4^2+1times 4^1+0times 4^0$



    This program takes n, then starts at v=0 and tests for this property and increments v until it finds n such numbers, then outputs the final one:



    bṖ’ḅi-µ#Ṫ - Main Link: no arguments
    # - set v=0 then count up collecting n=STDIN matches of:
    µ - the monadic link -- i.e. f(v): e.g. v=6
    Ṗ - pop (implicit range of v) [1,2,3,4,5]
    b - to base (vectorises) [[1,1,1,1,1,1],[1,1,0],[2,0],[1,2],[1,1]]
    ’ - decrement (vectorises) [[0,0,0,0,0,0],[0,0,-1],[1,-1],[0,1],[0,0]]
    ḅ - from base (v) (vectorises) [0,-1,5,1,0]
    - - literal -1 -1
    i - first index of (zero if not found) 2
    - } e.g. n=11 -> [6,12,14,20,30,39,42,56,62,72,84]
    Ṫ - tail -> 84
    - implicit print





    share|improve this answer











    $endgroup$




















      0












      $begingroup$

      JavaScript (ES7), 89 bytes



      1-indexed.





      n=>eval('for(a=[i=1e4];--i>1;)for(s=1e8+i,x=1;a[s+=i**++x]=x<26;);Object.keys(a)[n]-1e8')


      Try it online!






      share|improve this answer









      $endgroup$




















        0












        $begingroup$


        R, 65 bytes





        n=scan();unique(sort(apply(outer(2:n,1:n,"^"),1,cumsum)[-1,]))[n]


        Try it online!



        1-indexed.



        Generates a matrix of all values of the form $a^i$, takes the cumulative sum, removes the entries corresponding to $x=1$ (first row), then takes the unique sorted values.



        Note that sort(unique(...)) would not work, as unique would give unique rows of the matrix, and not unique entries. Using unique(sort(...)) works because sort converts to vector.





        share









        $endgroup$













          Your Answer






          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%2f183491%2fthe-nth-gryphon-number%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          5 Answers
          5






          active

          oldest

          votes








          5 Answers
          5






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          4












          $begingroup$


          MATL, 16 13 bytes



          :Qtt!^Ys+uSG)


          1-based.



          Try it online!



          Explanation



          Consider input n = 3 as an example.



          : % Implicit input: n. Range
          % STACK: [1 2 3]
          Q % Add 1, element-wise
          % STACK: [2 3 4]
          tt % Duplicate twice, transpose
          % STACK: [2 3 4], [2 3 4], [2;
          3;
          4]
          ^ % Power, element-wise with broadcast
          % STACK: [2 3 4], [ 4 9 16;
          8 27 64;
          16 81 256]
          Ys % Cumulative sum of each column
          % STACK: [2 3 4], [ 4 9 16;
          12 36 80;
          28 117 336]
          + % Add, element-wise with broadcast (*)
          % STACK: [ 6 12 20;
          14 39 84
          30 120 340]
          u % Unique elements. Gives a column vector
          % STACK: [ 6;
          14;
          30;
          12;
          ···
          340]
          S % Sort
          % STACK: [ 6;
          12
          14;
          20;
          ···
          340]
          G) % Push input again, index. This gets the n-th element. Implicit display
          % STACK: 14


          The matrix obtained in step (*) contains possibly repeated Gryphon numbers. In particular, it contains n distinct Gryphon numbers in its first row. These are not necessarily the n smallest Gryphon numbers. However, the lower-left entry 2+2^+···+2^n exceeds the upper-right entry n+n^2, and thus all the numbers in the last row exceed those in the first row. This implies that extending the matrix rightward or downward would not contribute any Gryphon number lower than the lowest n numbers in the matrix. Therefore, the matrix is guaranteed to contain the n smallest Gryphon numbers. Consequently, its n-th lowest unique element is the solution.






          share|improve this answer











          $endgroup$








          • 1




            $begingroup$
            What the hell, this is amazing!
            $endgroup$
            – IQuick 143
            59 mins ago















          4












          $begingroup$


          MATL, 16 13 bytes



          :Qtt!^Ys+uSG)


          1-based.



          Try it online!



          Explanation



          Consider input n = 3 as an example.



          : % Implicit input: n. Range
          % STACK: [1 2 3]
          Q % Add 1, element-wise
          % STACK: [2 3 4]
          tt % Duplicate twice, transpose
          % STACK: [2 3 4], [2 3 4], [2;
          3;
          4]
          ^ % Power, element-wise with broadcast
          % STACK: [2 3 4], [ 4 9 16;
          8 27 64;
          16 81 256]
          Ys % Cumulative sum of each column
          % STACK: [2 3 4], [ 4 9 16;
          12 36 80;
          28 117 336]
          + % Add, element-wise with broadcast (*)
          % STACK: [ 6 12 20;
          14 39 84
          30 120 340]
          u % Unique elements. Gives a column vector
          % STACK: [ 6;
          14;
          30;
          12;
          ···
          340]
          S % Sort
          % STACK: [ 6;
          12
          14;
          20;
          ···
          340]
          G) % Push input again, index. This gets the n-th element. Implicit display
          % STACK: 14


          The matrix obtained in step (*) contains possibly repeated Gryphon numbers. In particular, it contains n distinct Gryphon numbers in its first row. These are not necessarily the n smallest Gryphon numbers. However, the lower-left entry 2+2^+···+2^n exceeds the upper-right entry n+n^2, and thus all the numbers in the last row exceed those in the first row. This implies that extending the matrix rightward or downward would not contribute any Gryphon number lower than the lowest n numbers in the matrix. Therefore, the matrix is guaranteed to contain the n smallest Gryphon numbers. Consequently, its n-th lowest unique element is the solution.






          share|improve this answer











          $endgroup$








          • 1




            $begingroup$
            What the hell, this is amazing!
            $endgroup$
            – IQuick 143
            59 mins ago













          4












          4








          4





          $begingroup$


          MATL, 16 13 bytes



          :Qtt!^Ys+uSG)


          1-based.



          Try it online!



          Explanation



          Consider input n = 3 as an example.



          : % Implicit input: n. Range
          % STACK: [1 2 3]
          Q % Add 1, element-wise
          % STACK: [2 3 4]
          tt % Duplicate twice, transpose
          % STACK: [2 3 4], [2 3 4], [2;
          3;
          4]
          ^ % Power, element-wise with broadcast
          % STACK: [2 3 4], [ 4 9 16;
          8 27 64;
          16 81 256]
          Ys % Cumulative sum of each column
          % STACK: [2 3 4], [ 4 9 16;
          12 36 80;
          28 117 336]
          + % Add, element-wise with broadcast (*)
          % STACK: [ 6 12 20;
          14 39 84
          30 120 340]
          u % Unique elements. Gives a column vector
          % STACK: [ 6;
          14;
          30;
          12;
          ···
          340]
          S % Sort
          % STACK: [ 6;
          12
          14;
          20;
          ···
          340]
          G) % Push input again, index. This gets the n-th element. Implicit display
          % STACK: 14


          The matrix obtained in step (*) contains possibly repeated Gryphon numbers. In particular, it contains n distinct Gryphon numbers in its first row. These are not necessarily the n smallest Gryphon numbers. However, the lower-left entry 2+2^+···+2^n exceeds the upper-right entry n+n^2, and thus all the numbers in the last row exceed those in the first row. This implies that extending the matrix rightward or downward would not contribute any Gryphon number lower than the lowest n numbers in the matrix. Therefore, the matrix is guaranteed to contain the n smallest Gryphon numbers. Consequently, its n-th lowest unique element is the solution.






          share|improve this answer











          $endgroup$




          MATL, 16 13 bytes



          :Qtt!^Ys+uSG)


          1-based.



          Try it online!



          Explanation



          Consider input n = 3 as an example.



          : % Implicit input: n. Range
          % STACK: [1 2 3]
          Q % Add 1, element-wise
          % STACK: [2 3 4]
          tt % Duplicate twice, transpose
          % STACK: [2 3 4], [2 3 4], [2;
          3;
          4]
          ^ % Power, element-wise with broadcast
          % STACK: [2 3 4], [ 4 9 16;
          8 27 64;
          16 81 256]
          Ys % Cumulative sum of each column
          % STACK: [2 3 4], [ 4 9 16;
          12 36 80;
          28 117 336]
          + % Add, element-wise with broadcast (*)
          % STACK: [ 6 12 20;
          14 39 84
          30 120 340]
          u % Unique elements. Gives a column vector
          % STACK: [ 6;
          14;
          30;
          12;
          ···
          340]
          S % Sort
          % STACK: [ 6;
          12
          14;
          20;
          ···
          340]
          G) % Push input again, index. This gets the n-th element. Implicit display
          % STACK: 14


          The matrix obtained in step (*) contains possibly repeated Gryphon numbers. In particular, it contains n distinct Gryphon numbers in its first row. These are not necessarily the n smallest Gryphon numbers. However, the lower-left entry 2+2^+···+2^n exceeds the upper-right entry n+n^2, and thus all the numbers in the last row exceed those in the first row. This implies that extending the matrix rightward or downward would not contribute any Gryphon number lower than the lowest n numbers in the matrix. Therefore, the matrix is guaranteed to contain the n smallest Gryphon numbers. Consequently, its n-th lowest unique element is the solution.







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited 19 mins ago

























          answered 1 hour ago









          Luis MendoLuis Mendo

          75.4k889293




          75.4k889293







          • 1




            $begingroup$
            What the hell, this is amazing!
            $endgroup$
            – IQuick 143
            59 mins ago












          • 1




            $begingroup$
            What the hell, this is amazing!
            $endgroup$
            – IQuick 143
            59 mins ago







          1




          1




          $begingroup$
          What the hell, this is amazing!
          $endgroup$
          – IQuick 143
          59 mins ago




          $begingroup$
          What the hell, this is amazing!
          $endgroup$
          – IQuick 143
          59 mins ago











          1












          $begingroup$


          Wolfram Language (Mathematica), 59 bytes



          Union[Join@@Table[Sum[n^k,k,j],j,2,30,n,2,7!2]][[#]]&


          Try it online!



          1-indexed






          share|improve this answer









          $endgroup$

















            1












            $begingroup$


            Wolfram Language (Mathematica), 59 bytes



            Union[Join@@Table[Sum[n^k,k,j],j,2,30,n,2,7!2]][[#]]&


            Try it online!



            1-indexed






            share|improve this answer









            $endgroup$















              1












              1








              1





              $begingroup$


              Wolfram Language (Mathematica), 59 bytes



              Union[Join@@Table[Sum[n^k,k,j],j,2,30,n,2,7!2]][[#]]&


              Try it online!



              1-indexed






              share|improve this answer









              $endgroup$




              Wolfram Language (Mathematica), 59 bytes



              Union[Join@@Table[Sum[n^k,k,j],j,2,30,n,2,7!2]][[#]]&


              Try it online!



              1-indexed







              share|improve this answer












              share|improve this answer



              share|improve this answer










              answered 1 hour ago









              J42161217J42161217

              14.2k21353




              14.2k21353





















                  1












                  $begingroup$


                  Jelly, 9 bytes



                  bṖ’ḅi-µ#Ṫ


                  A full program which reads a (1-indexed) integer from STDIN and prints the result.



                  Try it online!



                  How?



                  A Gryphon number is a number which is expressible in a base less than itself such that all the digits are ones except the least significant, which is a zero. For example:



                  $30=1times 2^4+1times 2^3+1times2^2+1times2^1+0times2^0$



                  $84=1times 4^3+1times 4^2+1times 4^1+0times 4^0$



                  This program takes n, then starts at v=0 and tests for this property and increments v until it finds n such numbers, then outputs the final one:



                  bṖ’ḅi-µ#Ṫ - Main Link: no arguments
                  # - set v=0 then count up collecting n=STDIN matches of:
                  µ - the monadic link -- i.e. f(v): e.g. v=6
                  Ṗ - pop (implicit range of v) [1,2,3,4,5]
                  b - to base (vectorises) [[1,1,1,1,1,1],[1,1,0],[2,0],[1,2],[1,1]]
                  ’ - decrement (vectorises) [[0,0,0,0,0,0],[0,0,-1],[1,-1],[0,1],[0,0]]
                  ḅ - from base (v) (vectorises) [0,-1,5,1,0]
                  - - literal -1 -1
                  i - first index of (zero if not found) 2
                  - } e.g. n=11 -> [6,12,14,20,30,39,42,56,62,72,84]
                  Ṫ - tail -> 84
                  - implicit print





                  share|improve this answer











                  $endgroup$

















                    1












                    $begingroup$


                    Jelly, 9 bytes



                    bṖ’ḅi-µ#Ṫ


                    A full program which reads a (1-indexed) integer from STDIN and prints the result.



                    Try it online!



                    How?



                    A Gryphon number is a number which is expressible in a base less than itself such that all the digits are ones except the least significant, which is a zero. For example:



                    $30=1times 2^4+1times 2^3+1times2^2+1times2^1+0times2^0$



                    $84=1times 4^3+1times 4^2+1times 4^1+0times 4^0$



                    This program takes n, then starts at v=0 and tests for this property and increments v until it finds n such numbers, then outputs the final one:



                    bṖ’ḅi-µ#Ṫ - Main Link: no arguments
                    # - set v=0 then count up collecting n=STDIN matches of:
                    µ - the monadic link -- i.e. f(v): e.g. v=6
                    Ṗ - pop (implicit range of v) [1,2,3,4,5]
                    b - to base (vectorises) [[1,1,1,1,1,1],[1,1,0],[2,0],[1,2],[1,1]]
                    ’ - decrement (vectorises) [[0,0,0,0,0,0],[0,0,-1],[1,-1],[0,1],[0,0]]
                    ḅ - from base (v) (vectorises) [0,-1,5,1,0]
                    - - literal -1 -1
                    i - first index of (zero if not found) 2
                    - } e.g. n=11 -> [6,12,14,20,30,39,42,56,62,72,84]
                    Ṫ - tail -> 84
                    - implicit print





                    share|improve this answer











                    $endgroup$















                      1












                      1








                      1





                      $begingroup$


                      Jelly, 9 bytes



                      bṖ’ḅi-µ#Ṫ


                      A full program which reads a (1-indexed) integer from STDIN and prints the result.



                      Try it online!



                      How?



                      A Gryphon number is a number which is expressible in a base less than itself such that all the digits are ones except the least significant, which is a zero. For example:



                      $30=1times 2^4+1times 2^3+1times2^2+1times2^1+0times2^0$



                      $84=1times 4^3+1times 4^2+1times 4^1+0times 4^0$



                      This program takes n, then starts at v=0 and tests for this property and increments v until it finds n such numbers, then outputs the final one:



                      bṖ’ḅi-µ#Ṫ - Main Link: no arguments
                      # - set v=0 then count up collecting n=STDIN matches of:
                      µ - the monadic link -- i.e. f(v): e.g. v=6
                      Ṗ - pop (implicit range of v) [1,2,3,4,5]
                      b - to base (vectorises) [[1,1,1,1,1,1],[1,1,0],[2,0],[1,2],[1,1]]
                      ’ - decrement (vectorises) [[0,0,0,0,0,0],[0,0,-1],[1,-1],[0,1],[0,0]]
                      ḅ - from base (v) (vectorises) [0,-1,5,1,0]
                      - - literal -1 -1
                      i - first index of (zero if not found) 2
                      - } e.g. n=11 -> [6,12,14,20,30,39,42,56,62,72,84]
                      Ṫ - tail -> 84
                      - implicit print





                      share|improve this answer











                      $endgroup$




                      Jelly, 9 bytes



                      bṖ’ḅi-µ#Ṫ


                      A full program which reads a (1-indexed) integer from STDIN and prints the result.



                      Try it online!



                      How?



                      A Gryphon number is a number which is expressible in a base less than itself such that all the digits are ones except the least significant, which is a zero. For example:



                      $30=1times 2^4+1times 2^3+1times2^2+1times2^1+0times2^0$



                      $84=1times 4^3+1times 4^2+1times 4^1+0times 4^0$



                      This program takes n, then starts at v=0 and tests for this property and increments v until it finds n such numbers, then outputs the final one:



                      bṖ’ḅi-µ#Ṫ - Main Link: no arguments
                      # - set v=0 then count up collecting n=STDIN matches of:
                      µ - the monadic link -- i.e. f(v): e.g. v=6
                      Ṗ - pop (implicit range of v) [1,2,3,4,5]
                      b - to base (vectorises) [[1,1,1,1,1,1],[1,1,0],[2,0],[1,2],[1,1]]
                      ’ - decrement (vectorises) [[0,0,0,0,0,0],[0,0,-1],[1,-1],[0,1],[0,0]]
                      ḅ - from base (v) (vectorises) [0,-1,5,1,0]
                      - - literal -1 -1
                      i - first index of (zero if not found) 2
                      - } e.g. n=11 -> [6,12,14,20,30,39,42,56,62,72,84]
                      Ṫ - tail -> 84
                      - implicit print






                      share|improve this answer














                      share|improve this answer



                      share|improve this answer








                      edited 6 mins ago

























                      answered 27 mins ago









                      Jonathan AllanJonathan Allan

                      54.5k537174




                      54.5k537174





















                          0












                          $begingroup$

                          JavaScript (ES7), 89 bytes



                          1-indexed.





                          n=>eval('for(a=[i=1e4];--i>1;)for(s=1e8+i,x=1;a[s+=i**++x]=x<26;);Object.keys(a)[n]-1e8')


                          Try it online!






                          share|improve this answer









                          $endgroup$

















                            0












                            $begingroup$

                            JavaScript (ES7), 89 bytes



                            1-indexed.





                            n=>eval('for(a=[i=1e4];--i>1;)for(s=1e8+i,x=1;a[s+=i**++x]=x<26;);Object.keys(a)[n]-1e8')


                            Try it online!






                            share|improve this answer









                            $endgroup$















                              0












                              0








                              0





                              $begingroup$

                              JavaScript (ES7), 89 bytes



                              1-indexed.





                              n=>eval('for(a=[i=1e4];--i>1;)for(s=1e8+i,x=1;a[s+=i**++x]=x<26;);Object.keys(a)[n]-1e8')


                              Try it online!






                              share|improve this answer









                              $endgroup$



                              JavaScript (ES7), 89 bytes



                              1-indexed.





                              n=>eval('for(a=[i=1e4];--i>1;)for(s=1e8+i,x=1;a[s+=i**++x]=x<26;);Object.keys(a)[n]-1e8')


                              Try it online!







                              share|improve this answer












                              share|improve this answer



                              share|improve this answer










                              answered 15 mins ago









                              ArnauldArnauld

                              81.6k797336




                              81.6k797336





















                                  0












                                  $begingroup$


                                  R, 65 bytes





                                  n=scan();unique(sort(apply(outer(2:n,1:n,"^"),1,cumsum)[-1,]))[n]


                                  Try it online!



                                  1-indexed.



                                  Generates a matrix of all values of the form $a^i$, takes the cumulative sum, removes the entries corresponding to $x=1$ (first row), then takes the unique sorted values.



                                  Note that sort(unique(...)) would not work, as unique would give unique rows of the matrix, and not unique entries. Using unique(sort(...)) works because sort converts to vector.





                                  share









                                  $endgroup$

















                                    0












                                    $begingroup$


                                    R, 65 bytes





                                    n=scan();unique(sort(apply(outer(2:n,1:n,"^"),1,cumsum)[-1,]))[n]


                                    Try it online!



                                    1-indexed.



                                    Generates a matrix of all values of the form $a^i$, takes the cumulative sum, removes the entries corresponding to $x=1$ (first row), then takes the unique sorted values.



                                    Note that sort(unique(...)) would not work, as unique would give unique rows of the matrix, and not unique entries. Using unique(sort(...)) works because sort converts to vector.





                                    share









                                    $endgroup$















                                      0












                                      0








                                      0





                                      $begingroup$


                                      R, 65 bytes





                                      n=scan();unique(sort(apply(outer(2:n,1:n,"^"),1,cumsum)[-1,]))[n]


                                      Try it online!



                                      1-indexed.



                                      Generates a matrix of all values of the form $a^i$, takes the cumulative sum, removes the entries corresponding to $x=1$ (first row), then takes the unique sorted values.



                                      Note that sort(unique(...)) would not work, as unique would give unique rows of the matrix, and not unique entries. Using unique(sort(...)) works because sort converts to vector.





                                      share









                                      $endgroup$




                                      R, 65 bytes





                                      n=scan();unique(sort(apply(outer(2:n,1:n,"^"),1,cumsum)[-1,]))[n]


                                      Try it online!



                                      1-indexed.



                                      Generates a matrix of all values of the form $a^i$, takes the cumulative sum, removes the entries corresponding to $x=1$ (first row), then takes the unique sorted values.



                                      Note that sort(unique(...)) would not work, as unique would give unique rows of the matrix, and not unique entries. Using unique(sort(...)) works because sort converts to vector.






                                      share











                                      share


                                      share










                                      answered 26 secs ago









                                      Robin RyderRobin Ryder

                                      84112




                                      84112



























                                          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%2f183491%2fthe-nth-gryphon-number%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

                                          Category:Fedor von Bock Media in category "Fedor von Bock"Navigation menuUpload mediaISNI: 0000 0000 5511 3417VIAF ID: 24712551GND ID: 119294796Library of Congress authority ID: n96068363BnF ID: 12534305fSUDOC authorities ID: 034604189Open Library ID: OL338253ANKCR AUT ID: jn19990000869National Library of Israel ID: 000514068National Thesaurus for Author Names ID: 341574317ReasonatorScholiaStatistics

                                          Reverse int within the 32-bit signed integer range: [−2^31, 2^31 − 1]Combining two 32-bit integers into one 64-bit integerDetermine if an int is within rangeLossy packing 32 bit integer to 16 bitComputing the square root of a 64-bit integerKeeping integer addition within boundsSafe multiplication of two 64-bit signed integersLeetcode 10: Regular Expression MatchingSigned integer-to-ascii x86_64 assembler macroReverse the digits of an Integer“Add two numbers given in reverse order from a linked list”

                                          Kiel Indholdsfortegnelse Historie | Transport og færgeforbindelser | Sejlsport og anden sport | Kultur | Kendte personer fra Kiel | Noter | Litteratur | Eksterne henvisninger | Navigationsmenuwww.kiel.de54°19′31″N 10°8′26″Ø / 54.32528°N 10.14056°Ø / 54.32528; 10.14056Oberbürgermeister Dr. Ulf Kämpferwww.statistik-nord.deDen danske Stats StatistikKiels hjemmesiderrrWorldCat312794080n790547494030481-4