//g++ -Wall -o 1 1.cpp
//./1
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main() {
int n;
cin>>n;
if (n == 0){
cout<<0;
return 0;
}
else{
int a1 = 0 , a2 = 1;
int c = 1;
while(a2<=n){
if (a2==n){
cout<<c;
return 0;
}
a1 = a2;
a2 = a1+a2;
c++;
}
cout<<-1;
return 0;
}
}
Объяснение:
var x,y,nod,nok:longint;
begin
read(x,y);
a:=x; b:=y;
while (a>0) and (b>0) do
if a>b then a:=a mod b
else b:=b mod a;
nod:=a+b;
nok:=(x div nod)*y;
write(nok);
end;