Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int nwdwynik[30];
- long suma;
- int nwd(int a, int b) {
- while(a!=b)
- if(a>b) a-=b;
- else b-=a;
- return a;
- }
- int main() {
- int dane[60] = {24023, 30435, 5687, 12034, 7607, 3590, 4289, 13001, 7797, 13525, 14713, 6258, 10309, 22595, 14549, 22702, 15079, 31650, 15663, 32637, 11560, 27158, 13930, 2371, 26027, 7242, 29912, 5662, 4329, 9825, 12123, 26487, 30839, 16944, 13515, 23511, 24456, 18858, 19608, 23804, 2226, 13723, 2737, 29741, 18677, 29850, 6820, 30922, 19449, 11832, 17926, 3367, 28055, 18046, 14869, 23962, 19611, 13719, 20636, 21971};
- for(int i = 0; i < 58; i=i+2) {
- nwdwynik[i/2] = nwd(dane[i], dane[i+1]);
- }
- for(int i = 0; i < 29; i++) {
- suma = suma + nwdwynik[i];
- }
- cout << suma;
- return 0;
- }
Add Comment
Please, Sign In to add comment