| 
  • If you are citizen of an European Union member nation, you may not use this service unless you are at least 16 years old.

  • You already know Dokkio is an AI-powered assistant to organize & manage your digital files & messages. Very soon, Dokkio will support Outlook as well as One Drive. Check it out today!

View
 

PE030_c

Page history last edited by Kenneth Finnegan 15 years, 7 months ago

// Project Euler Problem #30

// sum of fifth powers of digits

#include <stdio.h>

int pow5(int i) { // pow() from math.h didn't link into my program for some reason

    return i*i*i*i*i;

}

main() {

    int i, sum=0;

    for (i=2; i<200000; i++) {

        int temp=i, tempsum=0;

        while (temp) {

            tempsum += pow5(temp%10);

            temp /= 10;

        }

        if (tempsum == i) {

            sum += i;

            printf("Solution found: %d, sum: %d\n", i, sum);

        }

    }

}

Comments (0)

You don't have permission to comment on this page.