Data update
This commit is contained in:
parent
4d5544505c
commit
4924dd0264
3073 changed files with 55820 additions and 4408 deletions
12
Task/Arithmetic-Rational/Pluto/arithmetic-rational.pluto
Normal file
12
Task/Arithmetic-Rational/Pluto/arithmetic-rational.pluto
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
local int = require "int"
|
||||
require "rat"
|
||||
|
||||
local one <const> = rat.of(1)
|
||||
print("The following numbers (less than 2^19) are perfect:")
|
||||
for i = 2, (1 << 19) - 1 do
|
||||
local sum = rat.of(1, i)
|
||||
local divs = int.divisors(i, true)
|
||||
divs:remove(1)
|
||||
for divs as j do sum += rat.of(1, j) end
|
||||
if sum == one then print($" {i}") end
|
||||
end
|
||||
|
|
@ -1,64 +1,63 @@
|
|||
-- 28 Jul 2025
|
||||
include Settings
|
||||
|
||||
say 'RATIONAL ARITHMETIC - 2 Mar 2025'
|
||||
say 'RATIONAL ARITHMETIC'
|
||||
say version
|
||||
say
|
||||
a = '1 2'; b = '-3 4'; c = '5 -6'; d = '-7 -8'; e = 3; f = 1.666666666
|
||||
say 'VALUES'
|
||||
say 'a =' Rlst2form(a)
|
||||
say 'b =' Rlst2form(b)
|
||||
say 'c =' Rlst2form(c)
|
||||
say 'd =' Rlst2form(d)
|
||||
say 'a =' Lst2FormQ(a)
|
||||
say 'b =' Lst2FormQ(b)
|
||||
say 'c =' Lst2FormQ(c)
|
||||
say 'd =' Lst2FormQ(d)
|
||||
say 'e =' e
|
||||
say 'f =' f
|
||||
say
|
||||
say 'BASICS'
|
||||
say 'a+b =' Rlst2form(Radd(a,b))
|
||||
say 'a+b+c+d =' Rlst2form(Radd(a,b,c,d))
|
||||
say 'a-b =' Rlst2form(Rsub(a,b))
|
||||
say 'a-b-c-d =' Rlst2form(Rsub(a,b,c,d))
|
||||
say 'a*b =' Rlst2form(Rmul(a,b))
|
||||
say 'a*b*c*d =' Rlst2form(Rmul(a,b,c,d))
|
||||
say 'a/b =' Rlst2form(Rdiv(a,b))
|
||||
say 'a/b/c/d =' Rlst2form(Rdiv(a,b,c,d))
|
||||
say '-a =' Rlst2form(Rneg(a))
|
||||
say '1/a =' Rlst2form(Rinv(a))
|
||||
say 'a+b =' Lst2FormQ(AddQ(a,b))
|
||||
say 'a+b+c+d =' Lst2FormQ(AddQ(a,b,c,d))
|
||||
say 'a-b =' Lst2FormQ(SubQ(a,b))
|
||||
say 'a-b-c-d =' Lst2FormQ(SubQ(a,b,c,d))
|
||||
say 'a*b =' Lst2FormQ(MulQ(a,b))
|
||||
say 'a*b*c*d =' Lst2FormQ(MulQ(a,b,c,d))
|
||||
say 'a/b =' Lst2FormQ(DivQ(a,b))
|
||||
say 'a/b/c/d =' Lst2FormQ(DivQ(a,b,c,d))
|
||||
say '-a =' Lst2FormQ(NegQ(a))
|
||||
say '1/a =' Lst2FormQ(InvQ(a))
|
||||
say
|
||||
say 'COMPARE'
|
||||
say 'a<b =' Rlt(a,b)
|
||||
say 'a<=b =' Rle(a,b)
|
||||
say 'a=b =' Req(a,b)
|
||||
say 'a>=b =' Rge(a,b)
|
||||
say 'a>b =' Rgt(a,b)
|
||||
say 'a<>b =' Rne(a,b)
|
||||
say 'Compare'
|
||||
say 'a<b =' LtQ(a,b)
|
||||
say 'a<=b =' LeQ(a,b)
|
||||
say 'a=b =' EqQ(a,b)
|
||||
say 'a>=b =' GeQ(a,b)
|
||||
say 'a>b =' GtQ(a,b)
|
||||
say 'a<>b =' NeQ(a,b)
|
||||
say
|
||||
say 'BONUS'
|
||||
say 'Abs(c) =' Rlst2form(Rabs(c))
|
||||
say 'Float(b) =' Rfloat(b)
|
||||
say 'Neg(d) =' Rlst2form(Rneg(d))
|
||||
say 'Power(a,e) =' Rlst2form(Rpow(a,e))
|
||||
say 'Rational(f) =' Rlst2form(Rrat(f))
|
||||
say 'Abs(c) =' Lst2FormQ(AbsQ(c))
|
||||
say 'Float(b) =' FloatQ(b)
|
||||
say 'Neg(d) =' Lst2FormQ(NegQ(d))
|
||||
say 'Power(a,e) =' Lst2FormQ(PowQ(a,e))
|
||||
say 'Rational(f) =' Lst2FormQ(RatQ(f))
|
||||
say
|
||||
say 'FORMULA'
|
||||
say 'a^2-2ab+3c-4ad^4+5 = ',
|
||||
Rlst2form(Radd(Rpow(a,2),Rmul(-2,a,b),Rmul(3,c),Rmul(-4,a,Rpow(d,4)),5))
|
||||
Lst2FormQ(AddQ(PowQ(a,2),MulQ(-2,a,b),MulQ(3,c),MulQ(-4,a,PowQ(d,4)),5))
|
||||
say
|
||||
say 'PERFECT NUMBERS'
|
||||
call time('r')
|
||||
say 'Perfect numbers'
|
||||
call Time('r')
|
||||
numeric digits 20
|
||||
do c = 6 to 2**19
|
||||
s = 1 c; m = Isqrt(c)
|
||||
do f = 2 to m
|
||||
if c//f = 0 then do
|
||||
s = Radd(s,1 f,1 c/f)
|
||||
s = AddQ(s,1 f,1 c/f)
|
||||
end
|
||||
end
|
||||
if Req(s,1) then
|
||||
if EqQ(s,1) then
|
||||
say c 'is a perfect number'
|
||||
end
|
||||
say time('e')/1's'
|
||||
say Time('e')/1's'
|
||||
exit
|
||||
|
||||
include Rational
|
||||
include Functions
|
||||
include Abend
|
||||
include Math
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue