同様の力を持つ数字


17

整数p> 1が与えられた場合、qの素因数分解の指数のリストが素因数の順序や値に関係なくpの指数と同じになるように、最小整数q> pを見つけます。

p = 20の素因数分解は2 2 x 5 1です。素因数分解で同じ指数を持つpより大きい最小整数はq = 28 = 2 2 x 7 1です。

p = 2500の素因数分解は2 2 x 5 4です。素因数分解で同じ指数を持つpより大きい最小整数は、q = 2704 = 2 4 x 13 2です。

ルール

  • 入力は1より大きい整数であることが保証されています。
  • これはであるため、バイト単位の最短回答が優先されます。

テストケース

Input | Output
------+-------
2     | 3
20    | 28
103   | 107
256   | 6561
768   | 1280
2500  | 2704
4494  | 4510
46552 | 46584
75600 | 105840

2
参考までに、これはOEISのA081761です。
ジョナサンフレッチ

回答:


9

、10バイト

§ḟ¤≡ȯÖLgp→

オンラインでお試しください!

外植

§ḟ       →     Find the first number starting from the input + 1 such that...
        p        The prime factorisation
       g         with equal elements grouped together
    ȯÖL          and sorted by length of groups
  ¤≡             has the same shape as the above applied to the input.

5

Mathematica、61バイト

(f[x_]:=Sort[Last/@FactorInteger@x];s=#;While[f@++s!=f@#];s)&  

オンラインでお試しください!

@Misha Lavrovから-4バイト


このようなWhileループを記述するより簡潔な方法はs=#;While[f@++s!=f@#];sです。
ミシャラヴロフ

1
を置き換えf[x_]f@x_バイトを保存できます。
numbermaniac

1
または、を定義するコンポジション-サラダルートに進みf=Last/@#&@*FactorInteger/*Sortます。
ミシャラヴロフ

4

Pyth、15バイト

fqFmShMrPd8,QTh

ここで試してみてください!またはすべてのテストケースを検証します。

これはどのように作動しますか?

fqFmShMrPd8,QTh   ~ Full program. Q = first input.

f             h   ~ First input where the condition is truthy over [Q+1, Q+2, ...]
           ,QT    ~ The two element list [Q, current value (T)].
   m              ~ Map over ^ with d.
       Pd         ~ The prime factorization of d.
      r  8        ~ Run-Length encode ^.
    hM            ~ Get the first element of each.
 qF               ~ Check if the values are equal.
                  ~ Output implicitly.

代替案

別の15バイト:

LShMrPb8fqyQyTh

そして、いくつかの(より長い)代替案:

fqFmSlM.gkPd,QTh
LSlM.gkPbfqyQyTh
LS/LPb{PbfqyQyTh
f!-FmlM.gkPd,QTh


4

Brachylog、13バイト

<.;?{ḋḅlᵐ}ᵐ=∧

オンラインでお試しください!

回答を投稿してから久しぶりです…

説明

<.               Input < Output
 .;?             The list [Output, Input]
    {    }ᵐ      Map on [Output, Input]:
     ḋ             Prime decomposition
      ḅ            Group into sublists of consecutive equal elements
       lᵐ          Take the length of each sublist
           =∧    The result of the map must be the same for the Output and the Input

4

パイソン2176の 179 171 170 169バイト

  • 変更問題として3つのバイトを追加しました指数のセット指数のリストset(f)に変更されましたsorted(f)
  • ovsのおかげで8バイト節約されました。if / elseブロックでゴルフをして、乗算までブロックします。
  • バイトを保存しました。にゴルフ(n!=r)した(n>r)
  • バイトを保存しました。にゴルフwhile N>1したwhile~-N
N=input();n=-~N
def F(N):
 r,f=0,[]
 while~-N:
	for n in range(2,-~N):
	 if N%n<1:f+=[1]*(n>r);f[-1]+=n==r;r=n;N/=n;break
 return sorted(f)
while F(N)!=F(n):n+=1
print n

オンラインでお試しください!


3

Haskell、107バイト

import Data.List
import Data.Numbers.Primes
p=sort.map(1<$).group.primeFactors
f x=until((==p x).p)(+1)$x+1

オンラインでお試しください!使用例:f 2500yields 2704

欠陥を指摘し、大量のバイトを保存してくれたnimiに感謝します。


組み込みなしprimeFactors(117バイト)

import Data.List
1%n=[]
x%n|0<-mod x n=n:div x n%n|m<-n+1=x%m
p=sort.map(1<$).group.(%2)
f x=until((==p x).p)(+1)$x+1

オンラインでお試しください!



2

05AB1E、15バイト

XµN‚εÓ0K{}ËNI›&

オンラインでお試しください!

説明

Xµ                # Loop over N in [0 ...] until 1 match is found
  N‚              # pair N with input
    ε    }        # apply to each
     Ó            # list prime exponents
      0K          # remove zeroes
        {         # sort
          Ë       # check that they are equal
              &   # and
           NI›    # that N is greater than the input

弊社のサイトを使用することにより、あなたは弊社のクッキーポリシーおよびプライバシーポリシーを読み、理解したものとみなされます。
Licensed under cc by-sa 3.0 with attribution required.