如何证明欧几里德算法的伪代码?

编程入门 行业动态 更新时间:2024-10-15 00:19:41
本文介绍了如何证明欧几里德算法的伪代码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

A(n,m): { if n==m, return(n) else { t = 1; while {n and m are divisible by 2} { t=2t, n = n/2, m=m/2 }; while {n is divisible by 2} n = n/2; while {m is divisible by 2} m=m/2; if n==m, return( t * n) else { k = m - n; while {k is divisible by 2} k=k/2; return( t * A( min(n,m), |k| ) ) } } }

推荐答案

通过形式验证证明代码确实是一项复杂的任务。 接受代码的常用方法因为'足够好'在一组已知输入上运行它,然后将其输出与预期输出进行比较。您可以通过将伪代码转换为实际程序来轻松实现。 Proving code by formal verification is really a complex task. A common way to accept code as 'good enough' is running it on a known set of inputs and then comparing its outputs with the expected ones. You might easily do that by translating the pseudo code into an actual program.

更多推荐

如何证明欧几里德算法的伪代码?

本文发布于:2023-11-30 17:01:15,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1650794.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:欧几里德   算法   代码

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!