Fermat’s Divisors Challenges

September 8, 2015

These are easy, though they run slowly, if you already have the necessary infrastructure; note that (sigma 1 n), which computes the sum of the divisors of n, is used somewhat differently below than it was in the definition of the challenge, though the two uses are algebraically identical:

> (do ((n 1 (+ n 1))) (#f) ; A008849
    (let* ((x (sigma 1 (* n n n)))
           (r (iroot 2 x)))
      (when (= x (* r r))
        (display n) (display "^3 = ")
        (display r) (display "^2") (newline))))
1^3 = 1^2
7^3 = 20^2
751530^3 = 1292054400^2
> (do ((n 1 (+ n 1))) (#f) ; A008850
    (let* ((x (sigma 1 (* n n)))
           (r (iroot 3 x)))
      (when (= x (* r r r))
        (display n) (display "^2 = ")
        (display r) (display "^3" (newline))))
1^2 = 1^3
43098^2 = 1729^3

Function iroot comes from a previous exercise, and my basic prime-number library, which includes the sigma function, appears on the next page. You can run the program at http://ideone.com/3iqiIH.

If you liked those challenges, here are three more:

1) Find numbers such that the sum of their divisors is a square; for instance, 66.

2) Find squares such that the sum of their divisors is a square; for instance, 81.

3) Find squares such that the sum of their aliquot divisors (divisors of n excluding n) is a square; for instance, 2401.

Advertisements

Pages: 1 2 3

4 Responses to “Fermat’s Divisors Challenges”

  1. Rutger said

    In Python.

    def sum_divisors_is_square(cube):
    	sum_divisors = sum([i for i in range(1,cube/2+1) if not cube % i]+[cube])
    	return sum_divisors ** 0.5 ==  int(sum_divisors**0.5)
    
    for i in range(10):
    	print i, sum_divisors_is_square(i**3)
    

    Finding divisors could be more efficient (iterate up through sqrt(n), if i is a divisor, then so is n/i). Also, Python’s range() function doesnt like big numbers, so should be transformed in a while loop.

  2. […] makes solving the Fermat Exponent problem […]

  3. Mayur Lokare said

    #include
    int main()
    {
    int i,sum,sq=0,l=0,n;
    printf(“Enter the Range\n”);
    scanf(“%d”,&n);
    for(i=1;i<n;i++)
    {
    sum=1+i+i*i+i*i*i;
    while(sq %d\n”,i,l);
    l=1;
    }
    }

    O/P:
    Enter the Range
    1000
    1 -> 2
    7 -> 20

  4. Mayur Lokare said

    EX 2.

    #include
    int main()
    {
    int i,sum,cu=0,l=0,n;
    printf(“Enter the Range\n”);
    scanf(“%d”,&n);
    for(i=1;i<n;i++)
    {
    sum=1+i+i*i;
    while(cu %d\n”,l,i);
    l=1;
    cu=0;
    }
    }

    O/P:
    Enter the Range
    1000
    7 -> 18

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: