Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //
- // main.c
- // Armstrong
- //
- // Created by Abdelali on 10/05/2016.
- // Copyright © 2016 Abdelaali. All rights reserved.
- //
- #include <stdio.h>
- int pow3(int x){
- return x*x*x;
- }
- int armstrong (int x){
- int c = x;
- int s = 0;
- while (c!=0) {
- s += pow3(c%10);
- c/=10;
- }
- if(x == s)
- return 1;
- return -1;
- }
- int main(int argc, const char * argv[]) {
- if(armstrong(153)) printf("amrstrong");
- else printf("ne pas");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement