Hello Mahmoud et All,
I added the
Erdős-Nicolas_numbers task to
Rosetta Code----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Definition
An Erdős–Nicolas number is a positive integer which is not perfect but is equal to the sum of its first k divisors (arranged in ascending order and including one) for some value of k greater than one.
Examples
24 is an Erdős–Nicolas number because the sum of its first 6 divisors
(1, 2, 3, 4, 6 and 8) is equal to 24 and it is not perfect because 12
is also a divisor.
6 is not an Erdős–Nicolas number because it is perfect (1 + 2 + 3 = 6).
48 is not an Erdős–Nicolas number because its divisors are: 1, 2,
3, 4, 6, 8, 12, 16, 24 and 48. The first seven of these add up to 36,
but the first eight add up to 52 which is more than 48.
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Code:see "works..." + nl
erdos = []
limit = 1600000
for n = 1 to limit
num = 0
sum = 0
erdos = []
for m = 1 to n/2
if n%m = 0
add(erdos,m)
ok
next
lenErdos = len(erdos)
for p = 1 to lenErdos
sum = sum + erdos[p]
if sum = n and p < lenErdos
num++
see "" + n + " equals the sum of its first " + p + " divisors" + nl
exit
ok
next
if num = 8
exit
ok
next
see "done..." + nl
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Output:works...
24 equals the sum of its first 6 divisors
2016 equals the sum of its first 31 divisors
8190 equals the sum of its first 43 divisors
42336 equals the sum of its first 66 divisors
45864 equals the sum of its first 66 divisors
714240 equals the sum of its first 113 divisors
392448 equals the sum of its first 68 divisors
1571328 equals the sum of its first 115 divisors
done...
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Have a nice day, good work and a pleasant rest.
Greetings,
Gal Zsolt
(~
CalmoSoft ~)
On Friday, 10 March 2023 at 15:01:09 UTC+1 Fuad Omari wrote:
the articles is by
CalmoSoft