Randbetween仅返回奇数 [英] Randbetween return only odd numbers

查看:57
本文介绍了Randbetween仅返回奇数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在Excel中创建两个边界之间的随机数列表.诀窍是数字需要为奇数.因此,我不能只使用 randbetween().我应该只使用 = if(a1%2 = 0)还是a1 = a1 + 1 .我不知道在Excel中的语法,但是我要知道的是如果数字是偶数(mod 2 = 0),然后加1.

I need to create a list of random numbers between two bounds in Excel. The trick is the numbers need to be odd. So I can't just use randbetween(). Should I just use something like =if(a1 % 2 =0) then a1=a1+1. I don't know the syntax for that in Excel but what I'm getting at is if the number is even (mod 2 =0) then add one.

推荐答案

使用一些技巧. CEILING Floor 具有第二个参数是您所需要的.

Use a little trick. CEILING and FLOOR have a second parameter which is what you need.

=CEILING(RANDBETWEEN(...),2)-1

这篇关于Randbetween仅返回奇数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆