Can a contract encode a paid request to perform some calculation?
For example, I would like to pay 1 ether to calculate the 100th prime number, and I want the Ethereum blockchain to calculate it for me. In another language, the code might look like this:
boolean function isPrime(int n) {
if(n < 2)
return false;
for (long i = 2; i * i <= n; i++)
if (n % i == 0)
return false;
return true;
}
for(int i = 1; ; i++) {
if(isPrime(i))
counter++;
if(counter == 100) {
print(i);
break;
}
}
The question is not about a contract on doing some work, but about Ethereum's ability to handle computations.