大数字相乘
Posted fly-book
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了大数字相乘相关的知识,希望对你有一定的参考价值。
/**
* 大数字相乘
*/
public class Test1
/**
* ints * num
* @param ints
* @param num
* @return
*/
public static int[] mul(int[] ints,int num)
for (int i = 0; i < ints.length; i++)
ints[i] *= num;
for (int i = ints.length-1; i > 0; i--)
ints[i-1] += ints[i]/10;
ints[i] = ints[i]%10;
return ints;
private static void console(int[] ints)
boolean flag = true;
for (int i = 0; i < ints.length; i++)
if (flag)
if (ints[i]!=0)
System.out.print(ints[i]);
flag = false;
else
System.out.print(ints[i]);
System.out.println();
/**
* num的阶乘
* @param num
*/
public static int[] factorial(int num)
int[] ints = new int[200];
ints[ints.length-1] = 1;
for (int i = 1; i <= num; i++)
ints = mul(ints,i);
return ints;
public static void main(String[] args)
int[] i = 1,1,0;
int num = 11;
// 110 * 11
console(mul(i, num));
// console(factorial(50));//30414093201713378043612608166064768844377641568960512000000000000
以上是关于大数字相乘的主要内容,如果未能解决你的问题,请参考以下文章