小编kul*_*lst的帖子

可以被1到100的所有数字整除的最小正数是多少?

以下是我的代码,我尝试使用BigInteger inn Java计算从1到100的所有数字的LCM.但它没有提供任何答案.

import java.math.BigInteger;

public class CommonOneToHundred {

    public static void main(String[] args) {
        // TODO Auto-generated method stub
        BigInteger res =new BigInteger("1");
        int i = 2;
        while(i<=100){
        res = lcm(res,BigInteger.valueOf(i));
        i++;
        }
        System.out.println(res);
    }
       static BigInteger lcm(BigInteger x, BigInteger y)
        {
            BigInteger a;
            //a = (x > y) ? x : y; // a is greater number
            a = y;
            while(true)
            {
                if(a.divide(x).equals(0) &&  a.divide(y).equals(0))
                    return a;
                a = a.add(BigInteger.ONE);
            }   
        }

}
Run Code Online (Sandbox Code Playgroud)

java biginteger lcm

3
推荐指数
1
解决办法
315
查看次数

垃圾值被插入到SQLite数据库中

在此输入图像描述将值插入数据库,正确插入整数值,但字符串值被某些垃圾值替换. 使用%s或%q作为字符串的占位符.

int sl_no1 = sl_no;
    int ac_no1 = account_no;
    string u_name = name;
    string u_add = address;
    int u_bal = bal;
    cout<<sl_no1<<endl<<ac_no1<<endl<<u_name<<endl<<u_add<<endl<<u_bal;

    /** Create SQL statement */
   //sql = "INSERT INTO ACCOUNT (SL_NO,ACCOUNT_NO, NMAE, ADDRESS, BALANCE) VALUES (" << sl_no1 <<", '"<< ac_no1 <<",'" << u_name <<", '"<< u_add <<", '" << u_bal << "')";
    sql = sqlite3_mprintf("INSERT INTO ACCOUNT VALUES('%d','%d','%q','%q','%d' )", sl_no1,ac_no1,u_name, u_add, u_bal);

    /** Execute SQL statement */
    rc = sqlite3_exec(db, sql, callback, 0, &zErrMsg);
    if( rc …
Run Code Online (Sandbox Code Playgroud)

c++ sqlite

1
推荐指数
1
解决办法
119
查看次数

标签 统计

biginteger ×1

c++ ×1

java ×1

lcm ×1

sqlite ×1