8-amaliy mashg’ulot Mavzu: Faktorlash muammosini bartaraf etuvchi dasturiy vositani ishlab chiqish


Download 92.38 Kb.
bet3/9
Sana18.06.2023
Hajmi92.38 Kb.
#1591825
1   2   3   4   5   6   7   8   9
Bog'liq
2-topshiriq (2)

Misol-1. n =728 soni tub ko‘paytuvchilari topilsin.
Yechish. Tasodifiy x0 ZnZ –son sifatida
x0 = 2 , f(x)=x2 +1
deb olinsa, u holda
xi f(xi-1) (mod n); i=0,1,2.......
yani x0 = 2, x1=5, x2 =26, x3 = 677, ………
EKUB (x1 - x0 ; n) = EKUB (3; 728)=1
Bu esa 3) shart intervaliga tegishli emas. Shuning uchun boshqa i – qiymatlar uchun hisoblashlarni davom qildiramiz.
EKUB (x2- x1; n) = EKUB ( 21; 728) =7;
Yani 3) shart intervaliga tushdi. Demak, 729:7=104. U holda bitta tub ko‘paytuvchisi 7 ekan. Keyingi hisoblashlarni n = 104 uchun bajarish yetarli.
EKUB (x1 - x0 ; n) = EKUB (3; 104)=1 , bu hol bajarilmaydi;
EKUB (x2- x1 ; n) = EKUB ( 21; 104) =1; bu hol ham bajarmadi;
EKUB (x3- x2 ; n) = EKUB ( 651; 104) =1; bu ham bajarmadi;
EKUB (x4- x3 ; n) = EKUB ( 457653; 104) =1; bu ham bajarmadi;
Demak, boshqa j, k –nomerlar uchun tekshiramiz:
j = 2, k = 0 ;
U holda
EKUB (x2 - x0; n) = EKUB ( 24; 104) = 8
va 1< 8 < 104 shart bajarildi.
Natijada 104: 8 = 13 bo‘lib, bevosita tekshirish mumkinki 13 soni tub son, javob esa 728 = 7*8*13= 7*23 *13.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Security.Cryptography;
using System.IO;
using System.Numerics;
namespace Pollard
{
class Program
{
static void Main(string[] args)
{
// Method Pollard p-1;
Console.Write("N=");
BigInteger n = BigInteger.Parse(Console.ReadLine());
int b = 8;
BigInteger a = 2;
BigInteger e = 2;
do
{
a=BigInteger.ModPow(a, e, n);
e = e + 1;
}
while (e<=b);
BigInteger p = BigInteger.GreatestCommonDivisor(a - 1, n);
if (p > 1 && p < n)
{
Console.Write("p=" + p);
}
// break;
Console.ReadKey();
} }}

Download 92.38 Kb.

Do'stlaringiz bilan baham:
1   2   3   4   5   6   7   8   9




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling