All pastes #77952 Raw Edit

Something

public text v1 · immutable
·published 2006-07-03 16:39 UTC
rendered paste body
#include <stdio.h>
#include <math.h>

#define MAX 2000090 

long int Tot[MAX]; /* Calculated Euler totients */
long int SumTot;

int main()
{
	long int n,
			i, j;

	scanf("%ld", &n);


	/* Apply Sieve to non-primes alone */
	for (i = 2; i<=n; i++){
		if (Tot[i] == 0) { 
			for (j = i; j <= n; j += i) {
				if(Tot[j] == 0)	/* Initialize */
					Tot[j] = j;
				Tot[j] = Tot[j]*(i-1)/i;
			}
		}
		SumTot += Tot[i];
	}

	printf("%ld\n", (long int)ceil( 1.44269504088896340736 * log(SumTot)) );

	
	return 0;
}