23 lines
489 B
C
Executable File
23 lines
489 B
C
Executable File
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <assert.h>
|
|
#include <math.h>
|
|
|
|
int main(int argc, char* argv[])
|
|
{
|
|
/// Syntaxe ./argv[0] x n
|
|
/// Resultat sur stdout : somme x^i avec i entre 0 et n
|
|
assert (argc == 3);
|
|
int x = atoi (argv[1]);
|
|
int n = atoi (argv[2]);
|
|
int somme = 0;
|
|
int i;
|
|
for (i = 0; i<=n ; i++)
|
|
{
|
|
somme+=pow(x,i);
|
|
printf ("... %d\n", somme);/// Mise au point
|
|
}
|
|
printf ("%d\n", somme);
|
|
return 0;
|
|
}
|