0% found this document useful (0 votes)
37 views2 pages

Static Int Int Int Int Do: Console Console Console

The document contains two C# functions: 'broj1' which calculates a specific number based on inputs 'a' and 'b', and 'prostbr' which counts the number of integers less than 'n' that are coprime to 'n'. The 'NZD' function is used to find the greatest common divisor, aiding in the coprime calculation. The main methods read user input and display results for both functionalities.

Uploaded by

Zemanic Izudin
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
37 views2 pages

Static Int Int Int Int Do: Console Console Console

The document contains two C# functions: 'broj1' which calculates a specific number based on inputs 'a' and 'b', and 'prostbr' which counts the number of integers less than 'n' that are coprime to 'n'. The 'NZD' function is used to find the greatest common divisor, aiding in the coprime calculation. The main methods read user input and display results for both functionalities.

Uploaded by

Zemanic Izudin
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

static int broj1(int a, int b, int i)

{
i = 1;
do
{
i = i * 10;
}
while (i <= a);
int trazeni_broj = a * i + b;
int novi = 0;
for (int k = 9; k >= 0; k--)
{
int nn = trazeni_broj;
while (nn > 0)
{
int c = nn % 10;
nn = nn / 10;
if (c == k) novi = novi * 10 + c;
}
}
return novi;
}
static void Main(string[] args)
{
int a = int.Parse(Console.ReadLine());
int b = int.Parse(Console.ReadLine());
int i=1;
Console.WriteLine("najveci broj je {0}",broj1(a,b,i));

}
5

static int prostbr(int n)


{
int br = 1;
for (int i = 2; i < n; i++)
{
if (NZD(n, i) == 1)
{
br++;
}
}
return br;
}
static int NZD(int a, int b)
{
int r;
do
{
r = a % b;
a = b; b = r;
} while (b > 0);
return a;
}
static void Main()
{
int n;
Console.Write("unesi broj ");
n = int.Parse(Console.ReadLine());
Console.WriteLine("broj prostih brojeva je: "+prostbr(n));
}

You might also like