Data update
This commit is contained in:
parent
81fd053722
commit
52a6ef48dd
10248 changed files with 63654 additions and 6775 deletions
23
Task/Arithmetic-Rational/FreeBASIC/arithmetic-rational.basic
Normal file
23
Task/Arithmetic-Rational/FreeBASIC/arithmetic-rational.basic
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
Const max = 1 Shl 19
|
||||
|
||||
Function frc(numerador As Double, denominador As Double = 1) As Double
|
||||
Return numerador / denominador
|
||||
End Function
|
||||
|
||||
Function isPerfect(valorEval As Uinteger) As Boolean
|
||||
Dim As Double sum = frc(1, valorEval)
|
||||
Dim As Uinteger max2 = Int(Sqr(valorEval))
|
||||
For factor As Uinteger = 2 To max2
|
||||
If (valorEval Mod factor) = 0 Then
|
||||
sum += frc(1, factor) + frc(1, valorEval \ factor)
|
||||
End If
|
||||
Next
|
||||
Return sum = frc(1)
|
||||
End Function
|
||||
|
||||
Dim As Double t0 = Timer
|
||||
For valorEval As Uinteger = 2 To max - 1
|
||||
If isPerfect(valorEval) Then Print valorEval & " is perfect"
|
||||
Next
|
||||
|
||||
Sleep
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
uses NumLibABC;
|
||||
|
||||
const
|
||||
max = 1 shl 19;
|
||||
|
||||
begin
|
||||
for var candidate := 2 to max - 1 do
|
||||
begin
|
||||
var sum := frc(1, candidate);
|
||||
var max2 := candidate.Sqrt.Trunc;
|
||||
for var factor := 2 to max2 do
|
||||
if (candidate mod factor) = 0 then
|
||||
sum += frc(1, factor) + frc(1, candidate div factor);
|
||||
if sum = frc(1) then
|
||||
Writeln(candidate, ' is perfect');
|
||||
end;
|
||||
end.
|
||||
Loading…
Add table
Add a link
Reference in a new issue