Skip to main content
We’ve updated our Terms of Service. A new AI Addendum clarifies how Stack Overflow utilizes AI interactions.
Code Golf

Return to Answer

deleted 23 characters in body
Source Link
Rosario
  • 1.7k
  • 5
  • 9

APL(NARS), 64 chars

r←B ×ばつ⍳w&l×ばつ(y+1)×ばつ⍳w>z⋄r←1

9+たす17+たす4+たす19+たす11+たす4=64

f(y)=×ばつ(y+1)×ばつ(y+2)=y^3+3y^2+2y is a crescent function and from y0=⌈(6w)^(1/3) => (y0)^3≥6w =>(y0)^3+3(y0)^2+2(y0)>6w so it is possible begin the loop in that point y0 and decrease y0 until (y0)^3+3(y0)^2+2(y0)≤6w

 a⊂⍨B ̈a←⍳123
 1 4 10 20 35 56 84 120 

it seems is possible to use big rational and big float too

 B 45487864677774111x
0
 B ×ばつ(45487864677774111x+1)×ばつ(45487864677774111x+2)÷6
1

but because is not implemented for rationals result for big number should not be ok

APL(NARS), 64 chars

r←B ×ばつ⍳w&l×ばつ(y+1)×ばつ⍳w>z⋄r←1

9+たす17+たす4+たす19+たす11+たす4=64

f(y)=×ばつ(y+1)×ばつ(y+2)=y^3+3y^2+2y is a crescent function and from y0=⌈(6w)^(1/3) => (y0)^3≥6w =>(y0)^3+3(y0)^2+2(y0)>6w so it is possible begin the loop in that point y0 and decrease y0 until (y0)^3+3(y0)^2+2(y0)≤6w

 a⊂⍨B ̈a←⍳123
 1 4 10 20 35 56 84 120 
 B 45487864677774111x
0
 B ×ばつ(45487864677774111x+1)×ばつ(45487864677774111x+2)÷6
1

but because is not implemented for rationals result for big number should not be ok

APL(NARS), 64 chars

r←B ×ばつ⍳w&l×ばつ(y+1)×ばつ⍳w>z⋄r←1

9+たす17+たす4+たす19+たす11+たす4=64

f(y)=×ばつ(y+1)×ばつ(y+2)=y^3+3y^2+2y is a crescent function and from y0=⌈(6w)^(1/3) => (y0)^3≥6w =>(y0)^3+3(y0)^2+2(y0)>6w so it is possible begin the loop in that point y0 and decrease y0 until (y0)^3+3(y0)^2+2(y0)≤6w

 a⊂⍨B ̈a←⍳123
 1 4 10 20 35 56 84 120 

it seems is possible to use big rational and big float too

 B 45487864677774111x
0
 B ×ばつ(45487864677774111x+1)×ばつ(45487864677774111x+2)÷6
1
added 94 characters in body
Source Link
Rosario
  • 1.7k
  • 5
  • 9

APL(NARS), 64 chars

r←B ×ばつ⍳w&l×ばつ(y+1)×ばつ⍳w>z⋄r←1

9+たす17+たす4+たす19+たす11+たす4=64

f(y)=×ばつ(y+1)×ばつ(y+2)=y^3+3y^2+2y is a crescent function and from y0=⌈(6w)^(1/3) => (y0)^3≥6w =>(y0)^3+3(y0)^2+2(y0)>6w so it is possible begin the loop in that point y0 and decrease y0 until (y0)^3+3(y0)^2+2(y0)≤6w

 a⊂⍨B ̈a←⍳123
 1 4 10 20 35 56 84 120 
 B 45487864677774111x
0
 B ×ばつ(45487864677774111x+1)×ばつ(45487864677774111x+2)÷6
1

but because is not implemented for rationals result for big number should not be ok

APL(NARS), 64 chars

r←B ×ばつ⍳w&l×ばつ(y+1)×ばつ⍳w>z⋄r←1

9+たす17+たす4+たす19+たす11+たす4=64

f(y)=×ばつ(y+1)×ばつ(y+2)=y^3+3y^2+2y is a crescent function and from y0=⌈(6w)^(1/3) => (y0)^3≥6w =>(y0)^3+3(y0)^2+2(y0)>6w so it is possible begin the loop in that point y0 and decrease y0 until (y0)^3+3(y0)^2+2(y0)≤6w

 a⊂⍨B ̈a←⍳123
 1 4 10 20 35 56 84 120 
 B 45487864677774111x
0
 B ×ばつ(45487864677774111x+1)×ばつ(45487864677774111x+2)÷6
1

APL(NARS), 64 chars

r←B ×ばつ⍳w&l×ばつ(y+1)×ばつ⍳w>z⋄r←1

9+たす17+たす4+たす19+たす11+たす4=64

f(y)=×ばつ(y+1)×ばつ(y+2)=y^3+3y^2+2y is a crescent function and from y0=⌈(6w)^(1/3) => (y0)^3≥6w =>(y0)^3+3(y0)^2+2(y0)>6w so it is possible begin the loop in that point y0 and decrease y0 until (y0)^3+3(y0)^2+2(y0)≤6w

 a⊂⍨B ̈a←⍳123
 1 4 10 20 35 56 84 120 
 B 45487864677774111x
0
 B ×ばつ(45487864677774111x+1)×ばつ(45487864677774111x+2)÷6
1

but because is not implemented for rationals result for big number should not be ok

added 179 characters in body
Source Link
Rosario
  • 1.7k
  • 5
  • 9

APL(NARS), 64 chars

r←B w;y;z
×ばつ6⋄r←0⋄→3×ばつ6⋄r←0⋄→3
y+←1y-←1
×ばつ⍳w&g×ばつ×ばつ⍳w&l×ばつ(y+1)×ばつy+2
×ばつ⍳w<z⋄r←1×ばつ⍳w>z⋄r←1

9+たす17+たす4+たす19+たす11+たす4=64

test:f(y)=×ばつ(y+1)×ばつ(y+2)=y^3+3y^2+2y is a crescent function and from y0=⌈(6w)^(1/3) => (y0)^3≥6w =>(y0)^3+3(y0)^2+2(y0)>6w so it is possible begin the loop in that point y0 and decrease y0 until (y0)^3+3(y0)^2+2(y0)≤6w

 a⊂⍨B ̈a←⍳123
 1 4 10 20 35 56 84 120 

note that this is ok even for big integers

 B 45487864677774111x
0
 B ×ばつ(45487864677774111x+1)×ばつ(45487864677774111x+2)÷6
1

APL(NARS), 64 chars

r←B w;y;z
×ばつ6⋄r←0⋄→3
y+←1
×ばつ⍳w&g×ばつ(y+1)×ばつy+2
×ばつ⍳w<z⋄r←1

9+たす17+たす4+たす19+たす11+たす4=64

test:

 a⊂⍨B ̈a←⍳123
 1 4 10 20 35 56 84 120 

note that this is ok even for big integers

 B 45487864677774111x
0
 B ×ばつ(45487864677774111x+1)×ばつ(45487864677774111x+2)÷6
1

APL(NARS), 64 chars

r←B w;y;z
×ばつ6⋄r←0⋄→3
y-←1
×ばつ⍳w&l×ばつ(y+1)×ばつy+2
×ばつ⍳w>z⋄r←1

9+たす17+たす4+たす19+たす11+たす4=64

f(y)=×ばつ(y+1)×ばつ(y+2)=y^3+3y^2+2y is a crescent function and from y0=⌈(6w)^(1/3) => (y0)^3≥6w =>(y0)^3+3(y0)^2+2(y0)>6w so it is possible begin the loop in that point y0 and decrease y0 until (y0)^3+3(y0)^2+2(y0)≤6w

 a⊂⍨B ̈a←⍳123
 1 4 10 20 35 56 84 120 
 B 45487864677774111x
0
 B ×ばつ(45487864677774111x+1)×ばつ(45487864677774111x+2)÷6
1
deleted 1 character in body
Source Link
Rosario
  • 1.7k
  • 5
  • 9
Loading
Source Link
Rosario
  • 1.7k
  • 5
  • 9
Loading

AltStyle によって変換されたページ (->オリジナル) /