Pagini recente » Cod sursa (job #147471) | Cod sursa (job #2068057) | Clasament fns_fanpage | Cod sursa (job #3173070) | Cod sursa (job #810234)
Cod sursa(job #810234)
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
/*
* main.cc
* Copyright (C) utilizatorul 2012 <utilizatorul@>
*
* ana-cifre-factorial is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* ana-cifre-factorial is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <iostream>
using namespace std;
unsigned int f (unsigned int x)
{
unsigned int s=0;
while (x) {
x = x/5;
s += x;
}
return s;
}
int main()
{
unsigned int x,y;
unsigned int n;
cout << "n=";
cin >> n;
if (n>100) {
cout << "fail\n";
return -1;
}
x = 5*((4*n)/5)+1;
while (true) {
y = f(x);
cout << "\t debug x=" << x << " y=" << y << "\n";
if (y==n) {
break;
}
if (y<n) {
x = x+5;
}
else {
cout << "problema nu are solutie\n";
return -2;
}
}
cout << x-1 << ", " << x << ", " << x+1 << ", " << x+2 << ", " << x+3 << "\n";
return 0;
}