My LeetCode grinding. Trying to do a problem a day.
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

main.rs 344B

1234567891011121314151617
  1. pub fn is_perfect_square(num: i32) -> bool {
  2. for x in 1..46341 {
  3. let res = (x as i32).pow(2);
  4. if res > num {
  5. return false;
  6. }
  7. if res == num {
  8. return true;
  9. }
  10. }
  11. return false;
  12. }
  13. fn main() {
  14. println!("Expected: true");
  15. println!("Got: {}", is_perfect_square(16));
  16. }