/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package gcd;
import java.util.Scanner;
/**
*
* @author Personal
*/
public class GCD {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
int a, b, q, r;
int s, s1, s2, t, t1, t2;
System.out.println("Mencari nilai s dan t pada persamaan s x a x t x b = gcd(a,b)");
Scanner A = new Scanner (System.in);
System.out.println("Nilai A = ");
a = A.nextInt();
Scanner B = new Scanner (System.in);
System.out.println("Nilai B = ");
b = B.nextInt();
s1 = 1;
s2 = 0;
t1 = 0;
t2 = 1;
do {
q = a / b;
r = a - b*q;
a = b;
b = r;
s = s1 - s2*q;
s1 = s2;
s2 = s;
t = t1-t2*q;
t1 = t2;
t2 = t;
}
while (b !=0);
System.out.println("GCD = "+a);
System.out.println("Nilai S = "+s1);
System.out.println("Nilai T = "+t1);
}
}
GCD.rar_expert
版权申诉
195 浏览量
2022-09-19
21:39:47
上传
评论
收藏 14KB RAR 举报
四散
- 粉丝: 54
- 资源: 1万+
最新资源
- 基于Python的酒店评论情感分析源码+文档(高分项目).zip
- meta-llama-3-8b-instruct 的 model-00003-of-00004.safetensors 的3/3
- nginx配置文件,注意其中需要对应宿主机的路径
- 自用数据集自用数据集自用数据集
- HTML5小游戏【堆雪人-优秀H5小游戏合集】游戏源码分享下载 - epicsnowman.zip
- SNMP Client 是SNMP测试工具
- Android Camera内存统计脚本
- AD9220高速数据芯片硬件参考设计原理图+STM32F103单片机驱动程序代码+芯片技术手册资料.zip
- 常用爆破用户名字典top500
- meta-llama-3-8b-instruct 的 model-00003-of-00004.safetensors 的2/3
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈