Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int najwiekszy(int a, int b)
- {
- while (a!=b) {
- if(a>b)
- a-=b;
- else
- b-=a;
- }
- return a;
- }
- int main()
- {
- int i = 2;
- int suma = 0;
- int x;
- int o1;
- cin>>o1;
- int o2;
- cin>>o2;
- while (i<1000000000) {
- cin>>x;
- if (x==1) {
- suma += najwiekszy(o1, o2);
- }
- else if (x==0) {
- break;
- }
- else if (x>1){
- o1 = o2;
- o2 = x;
- i++;
- }
- }
- cout<<suma;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement